EkNNval | R Documentation |
EkNNval
classifies instances in a test set using the EkNN classifier.
EkNNval(xtrain, ytrain, xtst, K, ytst = NULL, param = NULL)
xtrain |
Matrix of size ntrain x d, containing the values of the d attributes for the training data. |
ytrain |
Vector of class labels for the training data (of length ntrain). May be a factor, or a vector of integers from 1 to M (number of classes). |
xtst |
Matrix of size ntst x d, containing the values of the d attributes for the test data. |
K |
Number of neighbors. |
ytst |
Vector of class labels for the test data (optional). May be a factor, or a vector of integers from 1 to M (number of classes). |
param |
Parameters, as returned by |
If class labels for the test set are provided, the test error rate is also returned.
If parameters are not supplied, they are given default values by EkNNinit
.
A list with three elements:
Predicted mass functions for the test data. The first M columns correspond to the mass assigned to each class. The last column corresponds to the mass assigned to the whole set of classes.
Predicted class labels for the test data (coded as integers from 1 to M).
Test error rate.
Thierry Denoeux.
T. Denoeux. A k-nearest neighbor classification rule based on Dempster-Shafer theory. IEEE Transactions on Systems, Man and Cybernetics, 25(05):804–813, 1995.
L. M. Zouhal and T. Denoeux. An evidence-theoretic k-NN rule with parameter optimization. IEEE Transactions on Systems, Man and Cybernetics Part C, 28(2):263–271,1998.
EkNNinit
, EkNNfit
## Iris dataset
data(iris)
train<-sample(150,100)
xtrain<-iris[train,1:4]
ytrain<-iris[train,5]
xtst<-iris[-train,1:4]
ytst<-iris[-train,5]
K<-5
fit<-EkNNfit(xtrain,ytrain,K)
test<-EkNNval(xtrain,ytrain,xtst,K,ytst,fit$param)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.