Learn R Programming

traineR (version 2.2.11)

confusion.matrix: confusion.matrix

Description

create the confusion matrix.

Usage

confusion.matrix(newdata, prediction)

Value

A matrix with predicted and actual values.

Arguments

newdata

matrix or data frame of test data.

prediction

a prmdt prediction object.

Examples

Run this code

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)
modelo.knn
prob <- predict(modelo.knn, data.test, type = "prob")
prob
prediccion <- predict(modelo.knn, data.test, type = "class")
prediccion
confusion.matrix(data.test, prediccion)

Run the code above in your browser using DataLab