confusion_matrix: A confusion matrix

View source: R/confusion_matrix.R

confusion_matrixR Documentation

A confusion matrix

Description

A matrix, also known as a matching matrix or an error matrix, is a specific table layout that allows visualization of the performance of an algorithm, typically a supervised learning one. Each row of the matrix represents the instances in a predicted class for model 1 while each column represents the instances in class for model 2. The name stems from the fact that it makes it easy to see if the system is confusing two classes (i.e. commonly mislabeling one as another).

Usage

confusion_matrix(model1, model2, "ModelA", "ModelB")

Arguments

model1

A fitted model from the lcmm R package (or from SAS passed through the SASmodelbuilder() function)

model2

is the posterior probabilities of assignment of dimensions, K columns and N rows

name1

optional paramter to pre-specify name of model

name2

optional paramter to pre-specify name of model

Value

A confusion matrix between two models with the same number of classes

Examples

## Not run: 
data(bmi_long, package='LCTMtools')
library(lcmm)
model1 <- lcmm::hlme(BMI ~Age,
mixture= ~Age,
random= ~Age,
nwg=TRUE, ng=2, subject='ID', data=data.frame(bmi_long[1:500, ]))
model2 <- lcmm::hlme(BMI ~Age,
mixture= ~Age,
random= ~1,
nwg=FALSE, ng=2, subject='ID', data=data.frame(bmi_long[1:500, ]))
confusion_matrix(model1, model2)
## End(Not run)

hlennon/LCTMtools documentation built on Dec. 6, 2022, 3:04 a.m.