general_confusion_results {fastLogisticRegressionWrap}R Documentation

General Confusion Table and Errors

Description

Provides a confusion table and error metrics for general factor vectors. There is no need for the same levels in the two vectors.

Usage

general_confusion_results(yhat, yfac, proportions_scaled_by_column = FALSE)

Arguments

yhat

The factor predictions

yfac

The true factor responses

proportions_scaled_by_column

When returning the proportion table, scale by column? Default is FALSE to keep the probabilities unconditional to provide the same values as the function confusion_results. Set to TRUE to understand error probabilities by prediction bucket.

Value

A list of raw results

Examples

library(MASS); data(Pima.te)
ybin = as.numeric(Pima.te$type == "Yes")
flr = fast_logistic_regression(
  Xmm = model.matrix(~ . - type, Pima.te), 
  ybin = ybin
)
phat = predict(flr, model.matrix(~ . - type, Pima.te))
yhat = array(NA, length(ybin))
yhat[phat <= 1/3] = "no"
yhat[phat >= 2/3] = "yes"
yhat[is.na(yhat)] = "maybe"
general_confusion_results(factor(yhat, levels = c("no", "yes", "maybe")), factor(ybin)) 
#you want the "no" to align with 0, the "yes" to align with 1 and the "maybe" to be 
#last to align with nothing

[Package fastLogisticRegressionWrap version 1.2.0 Index]