This cookbook page introduces the application of linear discriminant analysis to multi-class classifications.
Imagine we have files with training and test data. We create CDenseFeatures (here 64 bit floats aka RealFeatures) and CMulticlassLabels
as
linear_discriminant_analysis.sg:create_features
We create an instance of the CMCLDA
classifier with feature matrix and label list. CMCLDA
also has two default parameters, to set tolerance used in training and mark whether to store the within class covariances.
linear_discriminant_analysis.sg:create_instance
Then we train and apply it to the test data, which here gives CMulticlassLabels
.
linear_discriminant_analysis.sg:train_and_apply
We can extract the mean vector of one class. If we enabled storing covariance when creating instances, we can also extract the covariance matrix:
linear_discriminant_analysis.sg:extract_mean_and_cov
We can evaluate test performance via e.g. CMulticlassAccuracy
.
linear_discriminant_analysis.sg:evaluate_accuracy
Linear_discriminant_analysis
Linear_discriminant_analysis#Multiclass_LDA