ipft (version 0.2.2)

ipfKnn: This function implements the k-nearest neighbors algorithm

Description

This function implements the k-nearest neighbors algorithm

Usage

ipfKnn(train, test, k = 3, method = "euclidean", norm = 2, sd = 5,
  epsilon = 0.001, alpha = 1, threshold = 20, FUN = NULL, ...)

Arguments

train
a data frame containing the RSSI vectors of the training set
test
a data frame containing the RSSI vectors of the test set
k
the k parameter for knn algorithm (number of nearest neighbors)
method
the method to compute the distance between the RSSI vectors: 'euclidean', 'manhattan', 'norm', 'LGD' or 'PLGD'
norm
parameter for the 'norm' method
sd
parameter for 'LGD' and 'PLGD' methods
epsilon
parameter for 'LGD' and 'PLGD' methods
alpha
parameter for 'PLGD' method
threshold
parameter for 'PLGD' method
FUN
an alternative function provided to compute the distance. This function must return a matrix of dimensions: nrow(test) x nrow(train), containing the distances from test observations to train observations
...
additional parameters for provided function FUN

Value

An S4 class object of type ipfModel, with the following slots: neighbors -> a matrix with k columns and nrow(test) rows, with the k nearest neighbors for each test observation weights -> a matrix with k columns and nrow(test) rows, with the weight for each neighbour distances -> a matrix with k columns and nrow(test) rows, with the distances between test and each neighbour k -> k parameter groups -> the group index for each training observation

Examples

Run this code

    model <- ipfKnn(ipftrain[, 1:168], ipftest[, 1:168])

    model <- ipfKnn(ipftrain[, 1:168], ipftest[, 1:168], k = 9, method = 'manhattan')

Run the code above in your browser using DataCamp Workspace