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);

 whos ('Mdl', 'CMdl')

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]

Variables visible from the current scope:

variables in scope: build_DEMOS: /home/promitheas/.local/share/octave/api-v59/packages/pkg-octave-doc-0.5.5/build_DEMOS.m

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  ===== 
         Mdl         1x1                          0  ClassificationDiscriminant
         CMdl        1x1                          0  ClassificationPartitionedModel

Total is 2 elements using 0 bytes