EkNNval {evclass} | R Documentation |
Classification of a test set by the EkNN classifier
Description
EkNNval
classifies instances in a test set using the EkNN classifier.
Usage
EkNNval(xtrain, ytrain, xtst, K, ytst = NULL, param = NULL)
Arguments
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 |
Details
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
.
Value
A list with three elements:
- m
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.
- ypred
Predicted class labels for the test data (coded as integers from 1 to M).
- err
Test error rate.
Author(s)
Thierry Denoeux.
References
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.
See Also
Examples
## 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)