# CompactRegressionGP

Package: classreg.learning.regr

Compact Gaussian process regression model class

## Description

`CompactRegressionGP` is a compact Gaussian process regression (GPR) model. The compact model consumes less memory than a full model, because it does not include the data used for training the GPR model.

Because the compact model does not include the training data, you cannot perform some tasks, such as cross-validation, using the compact model. However, you can use the compact model for making predictions or calculate regression loss for new data (use `predict` and `loss`).

## Construction

`compactMdl = compact(gprMdl)` returns a compact GPR model, `compactMdl`, from a full, trained GPR model, `gprMdl`. For more information, see `compact`.

### Input Arguments

expand all

Full, trained Gaussian process regression model, specified as a `RegressionGP` model, returned by `fitrgp`.

## Properties

expand all

Fitting

Method used to estimate the basis function coefficients, β; noise standard deviation, σ; and kernel parameters, θ, of the GPR model, stored as a character vector. It can be one of the following.

Fit MethodDescription
`'none'`No estimation. `fitrgp` uses the initial parameter values as the parameter values.
`'exact'`Exact Gaussian process regression.
`'sd'`Subset of data points approximation.
`'sr'`Subset of regressors approximation.
`'fic'`Fully independent conditional approximation.

Explicit basis function used in the GPR model, stored as a character vector or a function handle. It can be one of the following. If n is the number of observations, the basis function adds the term H*β to the model, where H is the basis matrix and β is a p-by-1 vector of basis coefficients.

Explicit BasisBasis Matrix
`'none'`Empty matrix.
`'constant'`

`$H=1$`

(n-by-1 vector of 1s, where n is the number of observations)

`'linear'`

`$H=\left[1,X\right]$`

`'pureQuadratic'`

`$H=\left[1,X,{X}_{2}\right],$`

where

`${X}_{2}=\left[\begin{array}{cccc}{x}_{11}^{2}& {x}_{12}^{2}& \cdots & {x}_{1d}^{2}\\ {x}_{21}^{2}& {x}_{22}^{2}& \cdots & {x}_{2d}^{2}\\ ⋮& ⋮& ⋮& ⋮\\ {x}_{n1}^{2}& {x}_{n2}^{2}& \cdots & {x}_{nd}^{2}\end{array}\right].$`

Function handle

Function handle, `hfcn`, that `fitrgp` calls as:

`$H=hfcn\left(X\right),$`

where `X` is an n-by-d matrix of predictors and H is an n-by-p matrix of basis functions.

Data Types: `char` | `function_handle`

Categorical predictor indices, specified as a vector of positive integers. `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: `single` | `double`

Estimated coefficients for the explicit basis functions, stored as a vector. You can define the explicit basis function by using the `BasisFunction` name-value pair argument in `fitrgp`.

Data Types: `double`

Estimated noise standard deviation of the GPR model, stored as a scalar value.

Data Types: `double`

Parameters used for training the GPR model, stored as a `GPParams` object.

Kernel Function

Form of the covariance function used in the GPR model, stored as a character vector containing the name of the built-in covariance function or a function handle. It can be one of the following.

FunctionDescription
`'squaredexponential'`Squared exponential kernel.
`'matern32'`Matern kernel with parameter 3/2.
`'matern52'`Matern kernel with parameter 5/2.
`'ardsquaredexponential'`Squared exponential kernel with a separate length scale per predictor.
`'ardmatern32'`Matern kernel with parameter 3/2 and a separate length scale per predictor.
`'ardmatern52'`Matern kernel with parameter 5/2 and a separate length scale per predictor.
Function handleA function handle that `fitrgp` can call like this:
`Kmn = kfcn(Xm,Xn,theta)`
where `Xm` is an m-by-d matrix, `Xn` is an n-by-d matrix and `Kmn` is an m-by-n matrix of kernel products such that `Kmn`(i,j) is the kernel product between `Xm`(i,:) and `Xn`(j,:).
`theta` is the r-by-1 unconstrained parameter vector for `kfcn`.

Data Types: `char` | `function_handle`

Information about the parameters of the kernel function used in the GPR model, stored as a structure with the following fields.

Field NameDescription
`Name`Name of the kernel function
`KernelParameters`Vector of the estimated kernel parameters
`KernelParameterNames`Names associated with the elements of `KernelParameters`.

Data Types: `struct`

Prediction

Method that `predict` uses to make predictions from the GPR model, stored as a character vector. It can be one of the following.

`PredictMethod`Description
`'exact'`Exact Gaussian process regression
`'bcd'`Block Coordinate Descent
`'sd'`Subset of Data points approximation
`'sr'`Subset of Regressors approximation
`'fic'`Fully Independent Conditional approximation

Weights used to make predictions from the trained GPR model, stored as a numeric vector. `predict` computes the predictions for a new predictor matrix `Xnew` by using the product

`$K\left({X}_{new},A\right)*\alpha \text{\hspace{0.17em}}.$`

$K\left({X}_{new},A\right)$ is the matrix of kernel products between ${X}_{new}$ and active set vector A and α is a vector of weights.

Data Types: `double`

Transformation applied to the predicted response, stored as a character vector describing how the response values predicted by the model are transformed. In `RegressionGP`, `ResponseTransform` is `'none'` by default, and `RegressionGP` does not use `ResponseTransform` when making predictions.

Active Set Selection

Subset of training data used to make predictions from the GPR model, stored as a matrix.

`predict` computes the predictions for a new predictor matrix `Xnew` by using the product

`$K\left({X}_{new},A\right)*\alpha \text{\hspace{0.17em}}.$`

$K\left({X}_{new},A\right)$ is the matrix of kernel products between ${X}_{new}$ and active set vector A and α is a vector of weights.

`ActiveSetVectors` is equal to the training data `X` for exact GPR fitting and a subset of the training data `X` for sparse GPR methods. When there are categorical predictors in the model, `ActiveSetVectors` contains dummy variables for the corresponding predictors.

Data Types: `double`

Method used to select the active set for sparse methods (`'sd'`,`'sr'`, or `'fic'`), stored as a character vector. It can be one of the following.

`ActiveSetMethod`Description
`'sgma'`Sparse greedy matrix approximation
`'entropy'`Differential entropy-based selection
`'likelihood'`Subset of regressors log likelihood-based selection
`'random'`Random selection

The selected active set is used in parameter estimation or prediction, depending on the choice of `FitMethod` and `PredictMethod` in `fitrgp`.

Size of the active set for sparse methods (`'sd'`,`'sr'`, or `'fic'`), stored as an integer value.

Data Types: `double`

## Object Functions

 `lime` Local interpretable model-agnostic explanations (LIME) `loss` Regression error for Gaussian process regression model `partialDependence` Compute partial dependence `plotPartialDependence` Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots `predict` Predict response of Gaussian process regression model `shapley` Shapley values

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.