ds.knn: K-Nearest Neighbour Classification

View source: R/ds.knn.R

ds.knnR Documentation

K-Nearest Neighbour Classification

Description

Perform a non-disclosive distributed K-Nearest Neighbour Classification

Usage

ds.knn(
  x,
  classificator,
  query,
  neigh = 3,
  method.indicator = "knn",
  k = 3,
  noise = 0.25,
  datasources = NULL
)

Arguments

x

character Name of the data frame on the server that has the dataset with a column that contains the classification objective

classificator

character Name of column on the table 'x' that has the classifier factor

query

numeric vector to be queried on the dataset to be classified, the length has to match the number of columns on the 'x' data frame minus one (the classification column is not included on the query obviously)

neigh

numeric (default 3) number of neighbours considered

method.indicator

character (default "knn") specifies the method that is used to generated non-disclosive coordinates to calculate the euclidean distance. This argument can be set as 'knn' or 'noise'. For more information see Details.

k

numeric (default 3) he number of the nearest neighbors for which their centroid is calculated. For more information see Details.

noise

numeric (default 0.25) the percentage of the initial variance that is used as the variance of the embedded noise if the argument method is set to 'noise'. For more information see Details.

datasources

a list of DSConnection-class (default NULL) objects obtained after login

Details

If the argument method is set to 'knn', the server-side function searches for the k-1 nearest neighbors of each single data point and calculates the centroid of such k points. The proximity is defined by the minimum Euclidean distances of z-score transformed data.

When the coordinates of all centroids are estimated the function applies scaling to expand the centroids back to the dispersion of the original data. The scaling is achieved by multiplying the centroids with a scaling factor that is equal to the ratio between the standard deviation of the original variable and the standard deviation of the calculated centroids. The coordinates of the scaled centroids are then returned to the client-side.

The value of k is specified by the user. The suggested and default value is equal to 3 which is also the suggested minimum threshold that is used to prevent disclosure which is specified in the protection filter nfilter.kNN. When the value of k increases, the disclosure risk decreases but the utility loss increases. The value of k is used only if the argument method is set to 'knn'. Any value of k is ignored if the argument method is set to 'noise'.

If the argument method is set to 'noise', the server-side function generates a random normal noise of zero mean and variance equal to 10\ The noise is added to each x and y variable and the disturbed by the addition of noise data are returned to the client-side. Note that the seed random number generator is fixed to a specific number generated from the data and therefore the user gets the same figure every time that chooses the knn method in a given set of variables. The value of noise is used only if the argument method is set to 'noise'. Any value of noise is ignored if the argument method is set to 'knn'.

Value

character with the classification assigned to the queried vector


isglobal-brge/dsMLClient documentation built on March 14, 2023, 1:59 p.m.