wknnor.Rd
Predicts labels for test data with ordinal nature or monotonic constraints using an adaptation of wknn.
wknnor(traindata, trainlabels, testdata, k, q, kerneltype, monotonicity)
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. |
Predicted labels for test data.
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 connectiontraindata=dattrain[,-ncol(dattrain)]#> Error in eval(expr, envir, enclos): object 'dattrain' not foundtrainlabels=dattrain[,ncol(dattrain)]#> Error in eval(expr, envir, enclos): object 'dattrain' not foundtestdata<-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 connectiontestlabels<-testdata[,ncol(testdata)]#> Error in eval(expr, envir, enclos): object 'testdata' not foundtestdata<-testdata[,-ncol(testdata)]#> Error in eval(expr, envir, enclos): object 'testdata' not foundpredictions<-wknnor(traindata,trainlabels,testdata,5,2,"rectangular",FALSE)#> Error in wknnor(traindata, trainlabels, testdata, 5, 2, "rectangular", FALSE): object 'trainlabels' not found