conf_mat: Confussion Matrix

View source: R/model_metrics.R

conf_matR Documentation

Confussion Matrix

Description

This function calculates a Confussion Matrix using crosstab for 2 or more categories. You can either set the score and threshold or the labels you wish to cross with.

Usage

conf_mat(tag, score, thresh = 0.5, sense = ">=", diagonal = TRUE, plot = FALSE)

Arguments

tag

Vector. Real known label

score

Vector. Predicted value or model's result

thresh

Integer. Threshold for selecting binary or regression models: this number is the threshold of unique values we should have in 'tag' (more than: regression; less than: classification)

sense

Character. Inequation sense for threshold: <, <=, >=, >

diagonal

Boolean. FALSE to convert diagonal numbers to zeroes. Ideal to detect must confusing categories.

plot

Boolean. Plot result? Uses mplot_conf()

Details

You may use mplot_conf() or set plot=TRUE.

Value

data.frame. Result of counting tag and score's tag given a threshold, similar to base::table().

See Also

Other Machine Learning: ROC(), export_results(), gain_lift(), h2o_automl(), h2o_predict_API(), h2o_predict_MOJO(), h2o_predict_binary(), h2o_predict_model(), h2o_selectmodel(), impute(), iter_seeds(), lasso_vars(), model_metrics(), model_preprocess(), msplit()

Other Model metrics: ROC(), errors(), gain_lift(), loglossBinary(), model_metrics()

Examples

data(dfr) # Results for AutoML Predictions
lapply(dfr[c(1, 2)], head)

# Results for Binomial Model
conf_mat(dfr$class2$tag, dfr$class2$scores)
conf_mat(dfr$class2$tag, dfr$class2$scores, thresh = 0.3)
conf_mat(dfr$class2$tag, dfr$class2$scores, sense = "<=")

# Results for Multi-Categorical Model
conf_mat(dfr$class3$tag, dfr$class3$score)

lares documentation built on Nov. 5, 2023, 1:09 a.m.