Main Content

CompactRegressionQuantileNeuralNetwork

Compact quantile neural network model for regression

Since R2025a

    Description

    CompactRegressionQuantileNeuralNetwork is a compact version of a RegressionQuantileNeuralNetwork model object. The compact model does not include the data used for training the quantile regression model. Therefore, you cannot use the compact model to perform certain tasks, such as cross-validation. Use the compact model for tasks such as predicting the response values of new data.

    Creation

    Create a CompactRegressionQuantileNeuralNetwork object from a full RegressionQuantileNeuralNetwork model object by using the compact function.

    Properties

    expand all

    Neural Network Properties

    This property is read-only.

    Quantiles used to train the quantile neural network regression model, returned as a vector of values in the range [0,1].

    Data Types: double

    This property is read-only.

    Sizes of the fully connected layers in the quantile neural network regression model, returned as a positive integer vector. Element i of LayerSizes is the number of outputs in the fully connected layer i of the model.

    LayerSizes does not include the size of the final fully connected layer. This layer always has one output for each quantile in Quantiles.

    Data Types: single | double

    This property is read-only.

    Learned layer weights for the fully connected layers, returned as a cell array. Entry i in the cell array corresponds to the layer weights for the fully connected layer i. For example, Mdl.LayerWeights{1} returns the weights for the first fully connected layer of the model Mdl.

    LayerWeights includes the weights for the final fully connected layer.

    Data Types: cell

    This property is read-only.

    Learned layer biases for the fully connected layers, returned as a cell array. Entry i in the cell array corresponds to the layer biases for the fully connected layer i. For example, Mdl.LayerBiases{1} returns the biases for the first fully connected layer of the model Mdl.

    LayerBiases includes the biases for the final fully connected layer.

    Data Types: cell

    This property is read-only.

    Activation functions for the fully connected layers of the quantile neural network regression model, returned as a character vector or cell array of character vectors with values from this table.

    ValueDescription
    "relu"

    Rectified linear unit (ReLU) function — Performs a threshold operation on each element of the input, where any value less than zero is set to zero, that is,

    f(x)={x,x00,x<0

    "tanh"

    Hyperbolic tangent (tanh) function — Applies the tanh function to each input element

    "sigmoid"

    Sigmoid function — Performs the following operation on each input element:

    f(x)=11+ex

    "none"

    Identity function — Returns each input element without performing any transformation, that is, f(x) = x

    • If Activations contains only one activation function, then it is the activation function for every fully connected layer of the model, excluding the final fully connected layer, which does not have an activation function (OutputLayerActivation).

    • If Activations is an array of activation functions, then element i is the activation function for layer i of the model.

    Data Types: char | cell

    This property is read-only.

    Activation function for the final fully connected layer, returned as 'none'.

    Data Types: char

    This property is read-only.

    Regularization term strength for the ridge (L2) penalty, returned as a nonnegative scalar.

    Data Types: double | single

    Data Properties

    This property is read-only.

    Predictor variable names, returned as a cell array of character vectors. The order of the elements of PredictorNames corresponds to the order in which the predictor names appear in the training data.

    Data Types: cell

    This property is read-only.

    Categorical predictor indices, returned as a vector of positive integers. Assuming that the predictor data contains observations in rows, CategoricalPredictors contains index values corresponding to the columns of the predictor data that contain categorical predictors. If none of the predictors are categorical, then this property is empty ([]).

    Data Types: double

    This property is read-only.

    Expanded predictor names, returned as a cell array of character vectors. If the model uses encoding for categorical variables, then ExpandedPredictorNames includes the names that describe the expanded variables. Otherwise, ExpandedPredictorNames is the same as PredictorNames.

    Data Types: cell

    This property is read-only.

    Predictor means, returned as a numeric vector. If you set Standardize to 1 or true when you train the neural network model, then the length of the Mu vector is equal to the number of expanded predictors (ExpandedPredictorNames). The vector contains 0 values for dummy variables corresponding to expanded categorical predictors.

    If you set Standardize to 0 or false when you train the neural network model, then the Mu value is an empty vector ([]).

    Data Types: double

    This property is read-only.

    Predictor standard deviations, returned as a numeric vector. If you set Standardize to 1 or true when you train the neural network model, then the length of the Sigma vector is equal to the number of expanded predictors (ExpandedPredictorNames). The vector contains 1 values for dummy variables corresponding to expanded categorical predictors.

    If you set Standardize to 0 or false when you train the neural network model, then the Sigma value is an empty vector ([]).

    Data Types: double

    This property is read-only.

    Response variable name, returned as a character vector.

    Data Types: char

    Response transformation function, specified as "none" or a function handle. ResponseTransform describes how the software transforms raw response values.

    For a MATLAB® function or a function that you define, enter its function handle. For example, you can enter Mdl.ResponseTransform = @function, where function accepts a numeric vector of the original responses and returns a numeric vector of the same size containing the transformed responses.

    Data Types: char | string | function_handle

    Object Functions

    lossLoss for quantile neural network regression model
    predictPredict response for quantile neural network regression model

    Examples

    collapse all

    Reduce the size of a full quantile neural network regression model by removing the training data. Full quantile regression models include the training data. You can use a compact quantile regression model to improve memory efficiency.

    Load the carbig data set, which contains measurements of cars made in the 1970s and early 1980s. Create a matrix X containing the predictor variables Acceleration, Displacement, Horsepower, and Weight. Store the response variable MPG in the variable Y.

    load carbig
    X = [Acceleration,Displacement,Horsepower,Weight];
    Y = MPG;

    Delete rows of X and Y where either array has missing values.

    R = rmmissing([X Y]);
    X = R(:,1:end-1);
    Y = R(:,end);

    Train a quantile neural network regression model. Specify to use the 0.25, 0.50, and 0.75 quantiles (that is, the lower quartile, median, and upper quartile). To improve the model fit, standardize the numeric predictors, and use a ridge (L2) regularization term of 0.05.

    rng(0,"twister") % For reproducibility
    Mdl = fitrqnet(X,Y,Quantiles=[0.25,0.50,0.75], ...
        Standardize=true,Lambda=0.05)
    Mdl = 
      RegressionQuantileNeuralNetwork
                 ResponseName: 'Y'
        CategoricalPredictors: []
                   LayerSizes: 10
                  Activations: 'relu'
        OutputLayerActivation: 'none'
                    Quantiles: [0.2500 0.5000 0.7500]
    
    
      Properties, Methods
    
    

    Mdl is a RegressionQuantileNeuralNetwork model object.

    Reduce the size of the quantile regression model.

    CompactMdl = compact(Mdl)
    CompactMdl = 
      CompactRegressionQuantileNeuralNetwork
                 ResponseName: 'Y'
        CategoricalPredictors: []
                   LayerSizes: 10
                  Activations: 'relu'
        OutputLayerActivation: 'none'
                    Quantiles: [0.2500 0.5000 0.7500]
    
    
      Properties, Methods
    
    

    CompactMdl is a CompactRegressionQuantileNeuralNetwork model object.

    Display the amount of memory used by each model.

    whos("Mdl","CompactMdl")
      Name            Size            Bytes  Class                                                            Attributes
    
      CompactMdl      1x1              5006  classreg.learning.regr.CompactRegressionQuantileNeuralNetwork              
      Mdl             1x1             47990  RegressionQuantileNeuralNetwork                                            
    

    The full quantile neural network regression model (Mdl) is more than nine times larger than the compact quantile neural network regression model (CompactMdl).

    To predict the response for new observations efficiently, you can remove Mdl from the MATLAB® Workspace, and then pass CompactMdl and new predictor values to predict.

    Version History

    Introduced in R2025a