ExNRule | R Documentation |
The function ExNRule() gives predictions and class probabilities for binary classification data using the extended neighbourhood rule (ExNRule) for k nearest neibour (kNN) ensemble.
ExNRule(xtrain, xtest, ytrain, k=3, r=500, p=round(sqrt(ncol(xtrain))))
xtrain |
The features space of the training dataset. |
xtest |
The feature space of the testing data. |
ytrain |
The response variable of the training dataset. |
k |
The nearest observation in the extended pattern. |
r |
The total number of base kNN models using ExNRule. |
p |
The number of features used for each base kNN model using ExNRule. |
class |
Predicted classes for the test data. |
class.prob |
Predicted class probabilities for the test data. |
Amjad Ali, Muhammad Hamraz, Saeed Aldahmani, Zardad Khan.
Maintainer: Amjad Ali <Amjad.ali@awkum.edu.pk>
Ali, Amjad, et al. "An Optimal k Nearest Neighbours Ensemble for Classification Based on Extended Neighbourhood Rule with Features subspace." arXiv preprint arXiv:2211.11278 (2022).
data(ILPD) X <- ILPD[,-11] Y <- as.factor(ILPD[,11]) n <- nrow(ILPD) train <- sample(1:n, 0.7*n, replace = FALSE) xtrain <- X[train,] xtest <- X[-train,] ytrain <- Y[train] ytest <- Y[-train] mymod <- ExNRule(xtrain, xtest, ytrain, k=3, r=500, p=round(sqrt(ncol(xtrain)))) pred.class <- mymod$class class.prob <- mymod$class.prob Accuracy <- mean(pred.class==ytest) ytestnum <- as.numeric(as.factor(ytest))-1 BrierScore <- mean((ytestnum-class.prob)^2) cbind(Accuracy, BrierScore)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.