confusion_matrix: Calculate confusion matrix and accuracy for Net Promoter...

Description Usage Arguments Examples

View source: R/confusion_matrix.R

Description

Calculate confusion matrix and accuracy for Net Promoter Category predicitons

Usage

1
2
3
confusion_matrix(m, test_data)

accuracy(m, test_data)

Arguments

m

Model output from model_survey

test_data

A data frame with test data in the same format as the input data for the model object

Examples

 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)

NateByers/NPSdrivers documentation built on May 6, 2019, 10:12 a.m.