View source: R/confusion_matrix.R
confusion_matrix | R Documentation |
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).
confusion_matrix(model1, model2, "ModelA", "ModelB")
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 |
A confusion matrix between two models with the same number of classes
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.