Categories &

Functions List

Class Definition: CompactClassificationGAM

statistics: CompactClassificationGAM

A CompactClassificationGAM object is a compact version of a Generalized Additive Model, ClassificationGAM.

The CompactClassificationDiscriminant does not include the training data resulting to a smaller classifier size, which can be used for making predictions from new data, but not for tasks such as cross validation. It can only be created from a ClassificationDiscriminant model by using the compact object method.

The available methods for a CompactClassificationGAM object are:

  • predict
  • savemodel

See also: fitcgam, compact, ClassificationGAM

Source Code: CompactClassificationGAM

Method: predict

CompactClassificationGAM: label = predict (obj, XC)
CompactClassificationGAM: label = predict (…, 'IncludeInteractions', includeInteractions)
CompactClassificationGAM: [label, score] = predict (…)

Predict labels for new data using the Generalized Additive Model (GAM) stored in a CompactClassificationGAM object.

label = predict (obj, XC) returns the predicted labels for the data in XC based on the model stored in the CompactClassificationGAM object, obj.

label = predict (obj, XC, 'IncludeInteractions', includeInteractions) allows you to specify whether interaction terms should be included when making predictions.

[label, score] = predict (…) also returns score, which contains the predicted class scores or posterior probabilities for each observation.

  • obj must be a CompactClassificationGAM class object.
  • XC must be an M×P numeric matrix where each row is an observation and each column corresponds to a predictor variable.
  • includeInteractions is a ’true’ or ’false’ indicating whether to include interaction terms in the predictions.

See also: CompactClassificationGAM, fitcgam

Method: savemodel

ClassificationGAM: savemodel (obj, filename)

Save a ClassificationGAM object.

savemodel (obj, filename) saves each property of a CompactClassificationGAM object into an Octave binary file, the name of which is specified in filename, along with an extra variable, which defines the type classification object these variables constitute. Use loadmodel in order to load a classification object into Octave’s workspace.

See also: loadmodel, fitcgam, ClassificationGAM, cvpartition, ClassificationPartitionedModel

Example: 1

 

 ## Create a generalized additive model classifier and its compact version
 # and compare their size

 load fisheriris
 X = meas;
 Y = species;

 Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
 CMdl = crossval (Mdl)

Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [4x4 struct]

CMdl =

  ClassificationPartitionedModel object with properties:

                   BinEdges: [0x0 double]
      CategoricalPredictors: [0x0 double]
                 ClassNames: [3x1 cell]
                       Cost: [3x3 double]
        CrossValidatedModel: ClassificationDiscriminant
                      KFold: [1x1 double]
            ModelParameters: [1x1 struct]
            NumObservations: [1x1 double]
                  Partition: [1x1 cvpartition]
             PredictorNames: [1x4 cell]
                      Prior: [3x1 double]
               ResponseName: Y
             ScoreTransform: none
                Standardize: [0x0 double]
                    Trained: [10x1 cell]
                          X: [150x4 double]
                          Y: [150x1 cell]