View source: R/general.indexes.R
general.indexes | R Documentation |
Calculates the confusion matrix, overall accuracy, overall error and the category accuracy for a classification problem and the Root Mean Square Error, Mean Absolute Error, Relative Error and Correlation for a regression problem.
general.indexes(newdata, prediction, mc = NULL)
newdata |
matrix or data frame of test data. |
prediction |
a prmdt prediction object. |
mc |
(optional) a matrix for calculating the indices. If mc is entered as parameter newdata and prediction are not necessary. |
A list with the appropiate error and precision measurement. The class of this list is indexes.prmdt
# Classification
data("iris")
n <- seq_len(nrow(iris))
.sample <- sample(n, length(n) * 0.75)
data.train <- iris[.sample,]
data.test <- iris[-.sample,]
modelo.knn <- train.knn(Species~., data.train)
prediccion <- predict(modelo.knn, data.test, type = "class")
general.indexes(data.test, prediccion)
# Regression
len <- nrow(swiss)
sampl <- sample(x = 1:len,size = len*0.20,replace = FALSE)
ttesting <- swiss[sampl,]
ttraining <- swiss[-sampl,]
model.knn <- train.knn(Infant.Mortality~.,ttraining)
prediccion <- predict(model.knn, ttesting)
prediccion
general.indexes(ttesting, prediccion)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.