Predicts labels for test data with ordinal nature or monotonic constraints using an adaptation of wknn.

wknnor(traindata, trainlabels, testdata, k, q, kerneltype, monotonicity)

Arguments

traindata

Training data of numeric type without labels.

trainlabels

A vector of numeric tags for each instance of training data.

testdata

Test data of numeric type.

k

number of neighbors to use.

q

Minkowski distance param. Use q=1 for Manhattan distance and q=2 for Euclidean distance.

kerneltype

Kernel used to compute neighbors weights. Avaiable kernels are: rectangular, triangular,epanechnikov, biweight, triweight, cosine, gauss and inversion.

monotonicity

Boolean param specifying whether data is monotone or not.

Value

Predicted labels for test data.

Examples

dattrain<-read.table("train_balance-scale.0", sep=" ")
#> Warning: cannot open file 'train_balance-scale.0': No such file or directory
#> Error in file(file, "rt"): cannot open the connection
traindata=dattrain[,-ncol(dattrain)]
#> Error in eval(expr, envir, enclos): object 'dattrain' not found
trainlabels=dattrain[,ncol(dattrain)]
#> Error in eval(expr, envir, enclos): object 'dattrain' not found
testdata<-read.table("test_balance-scale.0", sep=" ")
#> Warning: cannot open file 'test_balance-scale.0': No such file or directory
#> Error in file(file, "rt"): cannot open the connection
testlabels<-testdata[,ncol(testdata)]
#> Error in eval(expr, envir, enclos): object 'testdata' not found
testdata<-testdata[,-ncol(testdata)]
#> Error in eval(expr, envir, enclos): object 'testdata' not found
predictions<-wknnor(traindata,trainlabels,testdata,5,2,"rectangular",FALSE)
#> Error in wknnor(traindata, trainlabels, testdata, 5, 2, "rectangular", FALSE): object 'trainlabels' not found