simcam: SIMCA multiclass classification

View source: R/simcam.R

simcamR Documentation

SIMCA multiclass classification

Description

simcam is used to combine several one-class SIMCA models for multiclass classification.

Usage

simcam(models, info = "")

Arguments

models

list with SIMCA models (simca objects).

info

optional text with information about the the object.

Details

Besides the possibility for multiclass classification, SIMCAM also provides tools for investigation of relationship among individual models (classes), such as discrimination power of variables, Cooman's plot, model distance, etc.

When create simcam object, the calibration data from all individual SIMCA models is extracted and combined for making predictions and calculate performance of the multi-class model. The results are stored in $calres field of the model object.

Value

Returns an object of simcam class with following fields:

models

a list with provided SIMCA models.

dispower

an array with discrimination power of variables for each pair of individual models.

moddist

a matrix with distance between each each pair of individual models.

classnames

vector with names of individual classes.

nclasses

number of classes in the object.

info

information provided by user when create the object.

calres

an object of class simcamres with classification results for a calibration data.

See Also

Methods for simca objects:

print.simcam shows information about the object.
summary.simcam shows summary statistics for the models.
plot.simcam makes an overview of SIMCAM model with two plots.
predict.simcam applies SIMCAM model to a new data.
plotModelDistance.simcam shows plot with distance between individual models.
plotDiscriminationPower.simcam shows plot with discrimination power.
plotCooman.simcam shows Cooman's plot for calibration data.

Methods, inherited from classmodel class:

plotPredictions.classmodel shows plot with predicted values.
plotSensitivity.classmodel shows sensitivity plot.
plotSpecificity.classmodel shows specificity plot.
plotMisclassified.classmodel shows misclassified ratio plot.

Since SIMCAM objects and results are calculated only for optimal number of components, there is no sense to show such plots like sensitivity or specificity vs. number of components. However they are available as for any other classification model.

Examples

## make a multiclass SIMCA model for Iris data
library(mdatools)

# split data
caldata = iris[seq(1, nrow(iris), 2), 1:4]
x.se = caldata[1:25, ]
x.ve = caldata[26:50, ]
x.vi = caldata[51:75, ]

x.test = iris[seq(2, nrow(iris), 2), 1:4]
c.test = iris[seq(2, nrow(iris), 2), 5]

# create individual models
m.se = simca(x.se, classname = "setosa")
m.se = selectCompNum(m.se, 1)

m.vi = simca(x.vi, classname = "virginica")
m.vi = selectCompNum(m.vi, 2)

m.ve = simca(x.ve, classname = "versicolor")
m.ve = selectCompNum(m.ve, 1)

# combine models into SIMCAM objects, show statistics and plots
m = simcam(list(m.se, m.vi, m.ve), info = "simcam model for Iris data")
summary(m)

# show predictions and residuals for calibration data
par(mfrow = c(2, 2))
plotPredictions(m)
plotCooman(m, nc = c(1, 2))
plotModelDistance(m, nc = 1)
plotDiscriminationPower(m, nc = c(1, 2))
par(mfrow = c(1, 1))

# apply the SIMCAM model to test set and show statistics and plots
res = predict(m, x.test, c.test)
summary(res)
plotPredictions(res)


mdatools documentation built on Sept. 11, 2024, 7:59 p.m.