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 a ClassificationGAM object into a file defined by filename.

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 object with properties:

           ClassNames: [3x1 cell]
               Coeffs: [3x3 struct]
                 Cost: [3x3 double]
                Delta: [1x1 double]
          DiscrimType: linear
                Gamma: [1x1 double]
          LogDetSigma: [1x1 double]
             MinGamma: [1x1 double]
                   Mu: [3x4 double]
      NumObservations: [1x1 double]
        NumPredictors: [1x1 double]
       PredictorNames: [1x4 cell]
                Prior: [3x1 double]
         ResponseName: Y
             RowsUsed: [150x1 double]
       ScoreTransform: none
                Sigma: [4x4 double]
                    X: [150x4 double]
            XCentered: [150x4 double]
                    Y: [150x1 cell]

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]