fn_conf_mat {scorecardModelUtils}R Documentation

Creates confusion matrix and its related measures

Description

The function takes the base dataframe with observed/actual and predicted columns. The actual/predicted class preferably should be binary and if not, it will be considered as event vs rest. It computes the performance measures like accuracy, precision, recall, sensitivity, specificity and f1 score.

Usage

fn_conf_mat(base, observed_col, predicted_col, event)

Arguments

base

input dataframe

observed_col

column / field name of the observed event

predicted_col

column / field name of the predicted event

event

the event class, to be passed as string

Value

An object of class "fn_conf_mat" is a list containing the following components:

confusion_mat

confusion matrix as a table

accuracy

accuracy measure

precision

precision measure

recall

recall measure

sensitivity

sensitivity measure

specificity

specificity measure

f1_score

F1 score

Author(s)

Arya Poddar <aryapoddar290990@gmail.com>

Examples

data <- iris
data$Species <- as.character(data$Species)
suppressWarnings(RNGversion('3.5.0'))
set.seed(11)
data$Y <- sample(0:1,size=nrow(data),replace=TRUE)
data$Y_pred <- sample(0:1,size=nrow(data),replace=TRUE)
fn_conf_mat_list <- fn_conf_mat(base = data,observed_col = "Y",predicted_col = "Y_pred",event = 1)
fn_conf_mat_list$confusion_mat
fn_conf_mat_list$accuracy
fn_conf_mat_list$precision
fn_conf_mat_list$recall
fn_conf_mat_list$sensitivity
fn_conf_mat_list$specificity
fn_conf_mat_list$f1_score

[Package scorecardModelUtils version 0.0.1.0 Index]