
m
, models and search for the optimal models for classification.
esknnClass(xtrain, ytrain, k = NULL, q = NULL, m = NULL, ss = NULL)
n x d
dimension where n
is the number of traing
observation and d
is the number of features.Class
in the data..
NULL
then the default is set tok=3
.
m
.
NULL
the default is m=501
.
d
features for each bootstrap sample, when NULL
the
default is (number of features)/3
.
Predict.esknnClass
# Load the data
data(hepatitis)
data <- hepatitis
# Divide the data into testing and training parts
Class <- data[,names(data)=="Class"]
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 esknnClass
model<-esknnClass(xtrain, ytrain,k=NULL)
# Predict on test data
resClass<-Predict.esknnClass(model,xtest,ytest,k=NULL)
# Returning Objects are predicted class labels, confusion matrix and classification error
resClass$PredClass
resClass$ConfMatrix
resClass$ClassError
Run the code above in your browser using DataLab