Categories &

Functions List

Class Definition: CompactRegressionNeuralNetwork

statistics: CompactRegressionNeuralNetwork

Create a CompactRegressionNeuralNetwork object, a neural network regression model that has dropped its training data.

obj = CompactRegressionNeuralNetwork (Mdl) returns the compact form of the RegressionNeuralNetwork object Mdl. It is normally reached through compact (Mdl) rather than called directly.

The compact model keeps what is needed to answer about new data, the layer weights and biases, the activations, the standardization and the response transform, and drops what only describes the fit: the predictor and response data, the observation weights, the rows used, the number of observations and the iteration by iteration training history. predict and loss therefore agree with the full model to the last digit, while resubPredict and resubLoss do not exist here, there being no training data left to resubstitute.

See also: RegressionNeuralNetwork, fitrnet

Source Code: CompactRegressionNeuralNetwork

The CompactRegressionNeuralNetwork class contains the following properties:

A positive integer scalar. This property is read-only.

A cell array of character vectors. This property is read-only.

A character vector. This property is read-only.

A row vector with one entry per predictor, used for standardization. Empty when the predictor data were not standardized. This property is read-only.

A row vector with one entry per predictor, used for standardization. Empty when the predictor data were not standardized. This property is read-only.

A row vector of positive integers, one per hidden layer. This property is read-only.

A character vector, or a cell array of character vectors with one entry per hidden layer. This property is read-only.

A character vector. 'none' applies the identity, so a prediction is an unrestricted real number. This property is read-only.

A cell array with one entry per layer, the output layer included. This property is read-only.

A cell array with one entry per layer, the output layer included. This property is read-only.

A numeric vector of column indices, and empty when none is. This property is read-only.

A cell array of character vectors. This property is read-only.

A function handle, applied by predict to the network’s output. It may be set after construction, either to a handle or to the name of a supported transformation.

The CompactRegressionNeuralNetwork class offers the following public methods:

CompactRegressionNeuralNetwork: yFit = predict (obj, XC)

yFit = predict (obj, XC) returns a column vector holding the predicted response for each row of XC. It agrees with the full model this object was compacted from.

  • obj must be a CompactRegressionNeuralNetwork class object.
  • XC must be a numeric matrix with the same number of predictors as the data the model was trained on.

See also: CompactRegressionNeuralNetwork, RegressionNeuralNetwork

CompactRegressionNeuralNetwork: L = loss (obj, X, Y)
CompactRegressionNeuralNetwork: L = loss (…, name, value)

L = loss (obj, X, Y) returns the weighted mean squared error between the response Y and the response the model predicts for X.

  • obj must be a CompactRegressionNeuralNetwork class object.
  • X must be a numeric matrix with the same number of predictors as the data the model was trained on.
  • Y must be a numeric vector with as many rows as X.

L = loss (…, name, value) accepts the following Name-Value pairs.

NameValue
'LossFun''mse', the default, or a function handle called as lossfun (Y, yFit, W) and returning a scalar.
'Weights'A numeric vector of observation weights with one entry per row of X. It defaults to a uniform weight. The weights are normalized to sum to one before the loss is formed.

See also: CompactRegressionNeuralNetwork, RegressionNeuralNetwork

CompactRegressionNeuralNetwork: savemodel (obj, filename)

savemodel (obj, filename) saves every property of the CompactRegressionNeuralNetwork object obj into filename in binary format, so that it can be read back with loadmodel.

See also: loadmodel, CompactRegressionNeuralNetwork