Description Usage Arguments Value Author(s) References See Also Examples
View source: R/Predict.esknnProb.R
This function provides class membership probability estimates for the test set observations.
1 | Predict.esknnProb(optModels, xtest, ytest, k = NULL)
|
optModels |
An object of class esknnProb. |
xtest |
A matrix or data frame test set features/attributes. |
ytest |
Optional: A vector of class labels for the test data. Class labels should be factor of
two levels (0,1) represented by variable |
k |
Number of nearest neighbors considered. The same value should be considered as for training in |
PredProb |
A vector of estimated class membership probabilities of test set observations. |
BrierScore |
A vector of Brier Score based on the estimated probabilities and true class label of test set observations. This vector is returned if ytest is given. |
Asma Gul <agul@essex.ac.uk>
ul, A., Perperoglou, A., Khan, Z., Mahmoud, O.,Miftahuddin, M., Adler, W. and Lausen, B.(2014),Ensemble of Subset of kNN Classifiers, Journal name to appear.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Load the data
data(sonar)
data <- sonar
# Divide the data into testing and training parts
Class <- data[,names(data)=="Class"]
# Class Varible must be a factor in (0,1)
data$Class<-as.factor(as.numeric(Class)-1)
train <- data[sample(1:nrow(data),0.7*nrow(data)),]
test <- data[-(sample(1:nrow(data),0.7*nrow(data))),]
ytrain<-train[,names(train)=="Class"]
xtrain<-train[,names(train)!="Class"]
xtest<-test[,names(test)!="Class"]
ytest <- test[,names(test)=="Class"]
# Trian esknnProb
model<-esknnProb(xtrain, ytrain,k=NULL)
# Predict on test data
resProb<-Predict.esknnProb(model,xtest,ytest,k=NULL)
## Returning Objects
resProb$PredProb
resProb$BrierScore
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.