confusion.matrix: confusion.matrix

Description Usage Arguments Value Examples

View source: R/confusion.matrix.R

Description

create the confusion matrix.

Usage

1
confusion.matrix(newdata, prediction)

Arguments

newdata

matrix or data frame of test data.

prediction

a prmdt prediction object.

Value

A matrix with predicted and actual values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)

PROMiDAT/trainR documentation built on Oct. 27, 2020, 8:33 p.m.