calc_tpr: Measure model performance

Description Usage Arguments Examples

Description

This function evaluates a binary classification model. The function calculates true positive rate, false positive rate, true negative rate, false negative rate, and positive predictive value. These values are added to the data-frame provided in 'data'.

Usage

1
calc_tpr(pred_values, pos_pred, pos)

Arguments

data

data-frame that contains fitted values and known outcomes

predictor

column in 'data' that contains fitted values

known_class

column in 'data' that contains true or actual classification

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(tidyverse)
library(broom)
library(tidyroc)

# get `biopsy` dataset from `MASS`
data(biopsy, package = "MASS")

# change column names from `V1`, `V2`, etc. to informative variable names
colnames(biopsy) <-
 c("ID",
   "clump_thickness",
   "uniform_cell_size",
   "uniform_cell_shape",
   "marg_adhesion",
   "epithelial_cell_size",
   "bare_nuclei",
   "bland_chromatin",
   "normal_nucleoli",
   "mitoses",
   "outcome")

# fit a logistic regression model to predict tumour type
glm(outcome ~ clump_thickness + uniform_cell_shape,
   family = binomial,
   data = biopsy
) %>%
 augment() %>% # use broom to add glm output to the original data frame
 measure_perf(predictor = .fitted, known_class = outcome)

dariyasydykova/tidyroc documentation built on May 14, 2019, 11:03 p.m.