Categories &

Functions List

Class Definition: CompactClassificationNeuralNetwork

statistics: CompactClassificationNeuralNetwork

Compact neural network classification

The CompactClassificationNeuralNetwork class implements a compact version of the neural network classifier object, which can predict responses for new data using the predict method, but does not store the training data.

A compact neural network classification model is a smaller version of the full ClassificationNeuralNetwork model that does not include the training data. It consumes less memory than the full model, but cannot perform tasks that require the training data, such as cross-validation.

Create a CompactClassificationNeuralNetwork object by using the compact method on a ClassificationNeuralNetwork object.

See also: ClassificationNeuralNetwork, fitcnet

Source Code: CompactClassificationNeuralNetwork

The CompactClassificationNeuralNetwork class contains the following properties:

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

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A numeric vector containing the standard deviations of the predictors used for standardization. Empty when the predictor data were not standardized. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A numeric vector containing the means of the predictors used for standardization. Empty when the predictor data were not standardized. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A positive integer vector specifying the sizes of the fully connected layers in the neural network model. The i-th element of LayerSizes is the number of outputs in the i-th fully connected layer of the neural network model. LayerSizes does not include the size of the final fully connected layer. This layer always has K outputs, where K is the number of classes in Y. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A character vector or cell array of character vectors specifying the activation functions used in the hidden layers of the neural network. Supported activation functions include: 'linear', 'sigmoid', 'relu', 'tanh', 'softmax', 'lrelu', 'prelu', 'elu', and 'gelu'. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A character vector specifying the activation function of the output layer of the neural network. Supported activation functions are the same as for the Activations property. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A cell array holding one matrix per layer, the output layer included, with one row per neuron of that layer and one column per input it takes. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A cell array holding one column vector per layer, the output layer included, with one entry per neuron of that layer. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A numeric vector with one entry per class, in the order of ClassNames, summing to one. It is taken from the model this object was compacted from. This property is read-only.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

A numeric matrix with one row and one column per class, where Cost(i,j) is the cost of classifying an observation of class i as class j. It is taken from the model this object was compacted from. This property is read-only.

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.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

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

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

The CompactClassificationNeuralNetwork class offers the following public methods:

CompactClassificationNeuralNetwork: obj = CompactClassificationNeuralNetwork (Mdl)
CompactClassificationNeuralNetwork: obj = CompactClassificationNeuralNetwork ()

Mdl is the ClassificationNeuralNetwork object to compact. The documented way to reach this constructor is the compact method.

Called with no arguments it returns an object with its properties empty, which is how a saved model is rebuilt before its values are filled in.

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1
CompactClassificationNeuralNetwork: label = predict (obj, XC)
CompactClassificationNeuralNetwork: [label, score] = predict (obj, XC)

label = predict (obj, XC) returns the vector of labels predicted for the corresponding instances in XC, using the neural network model stored in the CompactClassificationNeuralNetwork model, obj.

  • obj must be a CompactClassificationNeuralNetwork class object.
  • XC must be an M×P numeric matrix with the same number of features P as the corresponding predictors of the neural network model in obj.

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

The score matrix contains the classification scores for each class. For each observation in XC, the predicted class label is the one with the highest score among all classes. If the ScoreTransform property is set to a transformation function, the scores are transformed accordingly before being returned.

See also: CompactClassificationNeuralNetwork, ClassificationNeuralNetwork, fitcnet

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1
CompactClassificationNeuralNetwork: 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 largest score it gives any other class. A positive margin means the observation is classified correctly, and the larger it is the more confidently so.

See also: CompactClassificationNeuralNetwork, ClassificationNeuralNetwork, edge, loss, predict

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1
CompactClassificationNeuralNetwork: e = edge (obj, X, Y)
CompactClassificationNeuralNetwork: 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: CompactClassificationNeuralNetwork, ClassificationNeuralNetwork, margin, loss, predict

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1
CompactClassificationNeuralNetwork: L = loss (obj, X, Y)
CompactClassificationNeuralNetwork: 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", "crossentropy", "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; "classifcost" charges what the model’s own prediction costs. "crossentropy" is defined for a network only. Note that the default differs from the other classifiers in this package, which default to "classiferror", and follows MATLAB’s for this class.
  • "Weights" holds one weight per row of X, normalised to sum to one before it is applied.

See also: CompactClassificationNeuralNetwork, ClassificationNeuralNetwork, margin, edge, predict

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1
CompactClassificationNeuralNetwork: savemodel (obj, filename)

savemodel (obj, filename) saves each property of a CompactClassificationNeuralNetwork 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, fitcnet, ClassificationNeuralNetwork

Train a neural network classifier and take its compact version, which drops the training data but predicts identically.

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1

Examples

 load fisheriris
 X = meas;
 Y = species;
 Mdl = fitcnet (X, Y, 'IterationLimit', 100)
Mdl =

  ClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
          NumObservations: 150
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'
                   Solver: 'LBFGS'
 CMdl = compact (Mdl)
CMdl =

  CompactClassificationNeuralNetwork

             ResponseName: 'Y'
               ClassNames: {'setosa' 'versicolor' 'virginica'}
           ScoreTransform: 'none'
            NumPredictors: 4
               LayerSizes: [10]
              Activations: 'relu'
    OutputLayerActivation: 'softmax'

The compact model keeps no training data

 isprop (Mdl, 'X')
ans = 1
 isprop (CMdl, 'X')
ans = 0

and predicts the same labels

 isequal (predict (Mdl, X), predict (CMdl, X))
ans = 1