Func.SNN: A function to calculate the shared nearest neighbors (SNN)

Description Usage Arguments Value Examples

View source: R/HighDimOut.R

Description

This function calculate the shared nearest neighbors (SNN). SNN is reported to be more robust than k nearest neighbors. Firstly, the k nearest neighbor distances for each observation is calculated. Then, the shared nearest neighbor similarity is calculated based on the result of k nearest neighbor. Note that k.nn should be greater than k.sel.

Usage

1
Func.SNN(data, k.nn, k.sel)

Arguments

data

is the data frame containing the observations (should be numeric data). Each row represents an observation and each variable is stored in one column.

k.nn

specifies the value used for calculating the shared nearest neighbors.

k.sel

specifies the number of shared nearest neighbors

Value

The function returns the matrix containing the indices of top k shared nearest neighbors for each observation

Examples

1
Func.SNN(data=TestData[,1:2], k.nn=5, k.sel=3)

Example output

    
X1    1  2  3
  1   2  8 18
  2   1  8 12
  3  20 25 15
  4   9  6 10
  5   7 16 56
  6   4  9 13
  7   5 16 15
  8  18  1  2
  9   4  6 10
  10  4  9 13
  11 14 23 24
  12  2 17  1
  13  6 10 22
  14 11 23 24
  15  3  7 16
  16  5  7 15
  17 12  1  2
  18  8  1  2
  19 21 15  1
  20  3 25  1
  21 19  3 15
  22  4 13 14
  23 11 14 24
  24 11 14 23
  25  3 20  8
  26 35 28 36
  27 39 51 30
  28 26 35 36
  29 44 52 48
  30 51 27 37
  31 41 32 33
  32 33 50 31
  33 32 50 31
  34 46 31 32
  35 26 28 36
  36 26 28 35
  37 45 27 30
  38 43 44 48
  39 27 49 51
  40 26 28 35
  41 31 47 32
  42 49 30 37
  43 38 44 48
  44 29 52 38
  45 37 27 30
  46 34 47 31
  47 41 46 31
  48 29 38 43
  49 39 42 27
  50 32 33 31
  51 27 30 39
  52 29 44 26
  53 11 14 23
  54 59  5  7
  55 58 11 53
  56  5 16  7
  57 53 58 11
  58 53 55 57
  59  5  7 16
  60 34 46 32

HighDimOut documentation built on May 2, 2019, 12:16 p.m.