Description Usage Arguments Examples
View source: R/confusion_matrix.R
Calculate confusion matrix and accuracy for Net Promoter Category predicitons
1 2 3 | confusion_matrix(m, test_data)
accuracy(m, test_data)
|
m |
Model output from |
test_data |
A data frame with test data in the same format as the input data for the model object |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(dplyr)
library(NPS)
library(caret)
data(survey_sim)
survey_sim <- survey_sim %>%
mutate(NPC = factor(npc(recommend), ordered = TRUE)) %>%
select(-recommend)
index <- createDataPartition(survey_sim$NPC, p = .8, list = FALSE, times = 1)
train <- survey_sim[index, ]
test <- survey_sim[-index, ]
m <- model_survey(train)
confusion_matrix(m, test)
accuracy(m, test)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.