Categories &

Functions List

Class Definition: CompactClassificationGAM

statistics: CompactClassificationGAM

Compact generalized additive model classification

The CompactClassificationGAM class is a compact version of a Generalized Additive Model classifier, ClassificationGAM. It does not include the training data, resulting in a smaller classifier size that can be used for making predictions from new data, but not for tasks such as cross validation.

A CompactClassificationGAM object can only be created from a ClassificationGAM model by using the compact method.

The engine that fitted the model is carried over in FitMethod, and the compact model predicts by the same scheme the full one did. Under 'boostedtrees', the default, the fit is described by TreeModel, BinEdges and PairDetectionBinEdges. Under 'splines' it is described by Formula, BaseModel, ModelwInt and IntMatrix, which MATLAB’s compact model does not carry. Whichever fitted the model, the other set is empty.

See also: ClassificationGAM, fitcgam

Source Code: CompactClassificationGAM

The CompactClassificationGAM class contains the following properties:

A positive integer value specifying the number of predictors in the training dataset used for training the ClassificationGAM model. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A cell array of character vectors specifying the names of the predictor variables. The names are in the order in which they appear in the training dataset. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A character vector specifying the name of the response variable Y. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

An array of unique values of the response variable Y, which has the same data types as the data in Y. This property is read-only. ClassNames can have any of the following datatypes:

  • Cell array of character vectors
  • Character array
  • Logical vector
  • Numeric vector

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A 2-element numeric vector specifying the prior probabilities for each class. The order of the elements in Prior corresponds to the order of the classes in ClassNames. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A character vector specifying the model formula in the form 'Y ~ terms' where Y represents the response variable and terms specifies the predictor variables and interaction terms. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A Kx2 matrix of predictor index pairs, one row per two-way term the model carries, and zeros (0, 2) when it carries none. It reports what was fitted rather than what was asked for, so a count of terms, 'all', a logical matrix and a formula all leave the same kind of value behind. This property is read-only.

A main effect names one predictor and a higher-order term names three or more, and neither has a two-column form, so neither appears here. IntMatrix remains the complete record of every term fitted.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A structure containing the parameters of the base model without any interaction terms. The base model represents the generalized additive model with only the main effects (predictor terms) included. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A structure containing the parameters of the model that includes interaction terms. This model extends the base model by adding interaction terms between predictors. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A logical matrix with one row per term and one column per predictor, true wherever the term multiplies that predictor. A row naming one predictor is a main effect, two an interaction, and three or more a higher-order term. This property is read-only.

It is the complete record, where Interactions reports only the two-way terms, in the form MATLAB reports them. It is also the form the 'Interactions' option takes back, so passing it to the constructor rebuilds a model over the same terms.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A numeric scalar, the log-odds of the response mean, which every additive term is measured against. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A numeric vector holding the column of each predictor treated as categorical, and empty when none is. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A cell array of character vectors naming the predictors as the model sees them. It matches PredictorNames unless a categorical predictor was expanded into dummy variables. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A cell array with one row vector per predictor, holding the cut points the boosted-tree engine binned it at. It is the empty cell under the spline engine, which does no binning. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A cell array with one coarse row vector per predictor, empty when the model carries no interaction terms. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

Either 'boostedtrees' or 'splines', as the model it was compacted from was fitted. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

The structure the full model reports, carried over unchanged, and empty under the spline engine. This property is read-only.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

A square matrix specifying the cost of misclassification of a point. Cost(i,j) is the cost of classifying a point into class j if its true class is i (that is, the rows correspond to the true class and the columns correspond to the predicted class). The order of the rows and columns in Cost corresponds to the order of the classes in ClassNames. The number of rows and columns in Cost is the number of unique classes in the response. By default, Cost(i,j) = 1 if i != j, and Cost(i,j) = 0 if i = j. In other words, the cost is 0 for correct classification and 1 for incorrect classification.

Add or change the Cost property using dot notation as in:

  • obj.Cost = costMatrix

A cost may also be given as a struct with the fields ClassNames and ClassificationCosts, which names the order its own matrix is written in. That matrix is permuted into the order of ClassNames above, so a caller need not know which order the classes were sorted into. It must name every class.

A cost must be floating point, not sparse, not complex, non-negative and zero down its diagonal, and must hold no NaN or Inf. A single is widened to double.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

Specified as a function handle for transforming the classification scores. Add or change the ScoreTransform property using dot notation as in:

  • obj.ScoreTransform = 'function_name'
  • obj.ScoreTransform = @function_handle

When specified as a character vector, it can be any of the following built-in functions. Nevertheless, the ScoreTransform property always stores their function handle equivalent.

ValueDescription
'doublelogit'1 ./ (1 + exp (-2 × x))
'invlogit'log (x ./ (1 - x))
'ismax'Sets the score for the class with the largest score to 1, and for all other classes to 0
'logit'1 ./ (1 + exp (-x))
'none'x (no transformation)
'identity'x (no transformation)
'sign' -1 for x < 0, 0 for x = 0, 1 for x > 0
'symmetric'2 × x - 1
'symmetricismax'Sets the score for the class with the largest score to 1, and for all other classes to -1
'symmetriclogit'2 ./ (1 + exp (-x)) - 1

The default is 'logit', as in MATLAB. This model’s raw score is a log-odds, reported as the pair [-f, f] whose two columns sum to zero, and the transform is what turns it into the posterior probabilities that sum to one. Every transform therefore composes on the log-odds and not on the probabilities, so 'none' returns the log-odds themselves.

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

The CompactClassificationGAM class offers the following public methods:

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

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

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

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

  • 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 logical scalar indicating whether to include interaction terms in the predictions.

See also: CompactClassificationGAM, ClassificationGAM, fitcgam

  1. A compact model drops the training data and predicts identically
 load fisheriris
 inds = ! strcmp (species, 'virginica');
 X = meas(inds, :);
 Y = species(inds);
 mdl = fitcgam (X, Y);
 cmdl = compact (mdl);

No X and no Y on the compact model, and the same labels out of it

 [isprop(mdl, 'X'), isprop(cmdl, 'X'), isequal(predict (mdl, X), predict (cmdl, X))]
ans =

  1  0  1
  1. The compact model assesses new data just as the full one does
 load fisheriris
 inds = ! strcmp (species, 'setosa');
 X = meas(inds, :);
 Y = species(inds);
 cmdl = compact (fitcgam (X, Y, 'NumTreesPerPredictor', 20));

margin, edge and loss are all available without the training data

 [edge(cmdl, X, Y), loss(cmdl, X, Y, 'LossFun', 'classiferror')]
ans =

   0.9930        0
CompactClassificationGAM: m = margin (obj, X, Y)

m = margin (obj, X, Y) returns a column vector holding, for each row of X, the score the model gives its true class in Y less the score it gives the other class. A positive margin means the observation is classified correctly, and the larger it is the more confidently so.

See also: CompactClassificationGAM, ClassificationGAM, edge, loss, predict

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'
CompactClassificationGAM: e = edge (obj, X, Y)
CompactClassificationGAM: e = edge (…, "Weights", w)

e = edge (obj, X, Y) returns the mean of the classification margins over the rows of X.

e = edge (…, "Weights", w) takes the weighted mean instead, with one weight per row of X.

See also: CompactClassificationGAM, ClassificationGAM, margin, loss, predict

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'
CompactClassificationGAM: L = loss (obj, X, Y)
CompactClassificationGAM: L = loss (…, name, value)

L = loss (obj, X, Y) returns the loss of the model on the rows of X against the true labels Y.

L = loss (…, name, value) accepts the following name-value pairs:

  • "LossFun" selects the loss. Supported values are "mincost", the default, "binodeviance", "classifcost", "classiferror", "exponential", "hinge", "logit" and "quadratic". "mincost" assigns each observation to the class of least expected cost and charges what that assignment costs, so it reads the scores as a posterior, which is what this model returns; "classifcost" charges what the model’s own prediction costs.
  • "Weights" holds one weight per row of X, normalised to sum to one before it is applied.

See also: CompactClassificationGAM, ClassificationGAM, margin, edge, predict

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'
CompactClassificationGAM: savemodel (obj, filename)

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, CompactClassificationGAM

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))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'

Examples

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =

  ClassificationDiscriminant

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
              DiscrimType: 'linear'
                       Mu: [3x4 double]
                   Coeffs: [3x3 struct]
 CMdl = crossval (Mdl)
CMdl =

  ClassificationPartitionedModel

      CrossValidatedModel: 'Discriminant'
             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
          NumObservations: 150
                    KFold: 10
           ScoreTransform: 'none'