gaussian process regression model -凯发k8网页登录
gaussian process regression model
description
regressiongp
is a gaussian process regression (gpr) model.
you can train a gpr model, using fitrgp
. using the trained model,
you can
predict responses for training data using
resubpredict
or new predictor data usingpredict
. you can also compute the prediction intervals.compute the regression loss for training data using
resubloss
or new data usingloss
.
creation
create a regressiongp
object by using fitrgp
.
properties
fitting
fitmethod
— method used to estimate the parameters
'none'
| 'exact'
| 'sd'
| 'sr'
| 'fic'
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 method | description |
---|---|
'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. |
basisfunction
— explicit basis function
'none'
| 'constant'
| 'linear'
| 'purequadratic'
| function handle
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 basis | basis matrix |
---|---|
'none' | empty matrix. |
'constant' |
(n-by-1 vector of 1s, where n is the number of observations) |
'linear' |
|
'purequadratic' |
where |
function handle | function handle, where |
data types: char
| function_handle
beta
— estimated coefficients
vector
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
sigma
— estimated noise standard deviation
scalar value
estimated noise standard deviation of the gpr model, stored as a scalar value.
data types: double
categoricalpredictors
— indices of categorical predictors
vector of positive integers | []
categorical predictor
indices, specified as a vector of positive integers. categoricalpredictors
contains index values indicating that the corresponding predictors are categorical. the index
values are between 1 and p
, where p
is the number of
predictors used to train the model. if none of the predictors are categorical, then this
property is empty ([]
).
data types: single
| double
hyperparameteroptimizationresults
— cross-validation optimization of hyperparameters
bayesianoptimization
object | table
this property is read-only.
cross-validation optimization of hyperparameters, specified as a bayesianoptimization
object or a table of hyperparameters and associated
values. this property is nonempty if the 'optimizehyperparameters'
name-value pair argument is nonempty when you create the model. the value of
hyperparameteroptimizationresults
depends on the setting of the
optimizer
field in the
hyperparameteroptimizationoptions
structure when you create the
model.
value of optimizer field | value of hyperparameteroptimizationresults |
---|---|
'bayesopt' (default) | object of class bayesianoptimization |
'gridsearch' or 'randomsearch' | table of hyperparameters used, observed objective function values (cross-validation loss), and rank of observations from lowest (best) to highest (worst) |
loglikelihood
— maximized marginal log likelihood
scalar value | []
maximized marginal log likelihood of the gpr model, stored as a scalar
value if the fitmethod
is different from
'none'
. if fitmethod
is
'none'
, then loglikelihood
is empty.
if fitmethod
is 'sd'
,
'sr'
, or 'fic'
, then
loglikelihood
is the maximized approximation of
the marginal log likelihood of the gpr model.
data types: double
modelparameters
— parameters used for training
gpparams
object
parameters used for training the gpr model, stored as a gpparams
object.
kernel function
kernelfunction
— form of the covariance function
'squaredexponential'
| 'matern32'
| 'matern52'
| 'ardsquaredexponential'
| 'ardmatern32'
| 'ardmatern52'
| function handle
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.
function | description |
---|---|
'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 handle | a 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
kernelinformation
— information about the parameters of the kernel function
structure
information about the parameters of the kernel function used in the gpr model, stored as a structure with the following fields.
field name | description |
---|---|
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
predictmethod
— method used to make predictions
'exact'
| 'bcd'
| 'sd'
| 'sr'
| 'fic'
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 |
alpha
— weights
numeric vector
weights used to make predictions from the trained gpr model,
stored as a numeric vector. predict
computes the
predictions for a new predictor matrix by
using the product
is the matrix of kernel products between and active set vector a and α is a vector of weights.
data types: double
bcdinformation
— information on bcd-based computation of alpha
structure | []
information on block coordinate descent (bcd)-based computation of
alpha
when predictmethod
is 'bcd'
, stored as a structure containing the
following fields.
field name | description |
---|---|
gradient | n-by-1 vector containing the gradient of the bcd objective function at convergence. |
objective | scalar containing the bcd objective function at convergence. |
selectioncounts | n-by-1 integer vector indicating the number of times each point was selected into a block during bcd. |
alpha
property contains the
alpha
vector computed from bcd.
if predictmethod
is not 'bcd'
,
then bcdinformation
is empty.
data types: struct
responsetransform
— transformation applied to predicted response
'none'
(default)
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
activesetvectors
— subset of training data
matrix
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 by using the product
is the matrix of kernel products between 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
activesethistory
— history of active set selection and parameter estimation
structure
history of interleaved active
set selection and parameter estimation for
fitmethod
equal to 'sd'
,
'sr'
, or 'fic'
, stored as a
structure with the following fields.
field name | description |
---|---|
parametervector | cell array containing the parameter vectors: basis function coefficients, β, kernel function parameters θ, and noise standard deviation σ. |
activesetindices | cell array containing the active set indices. |
loglikelihood | vector containing the maximized log likelihoods. |
criterionprofile | cell array containing the active set selection criterion values as the active set grows from size 0 to its final size. |
data types: struct
activesetmethod
— method used to select the active set
'sgma'
| 'entropy'
| 'likelihood'
| 'random'
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
.
activesetsize
— size of the active set
integer value
size of the active set for sparse methods ('sd'
,'sr'
,
or 'fic'
), stored as an integer value.
data types: double
isactivesetvector
— indicators for selected active set
logical vector
indicators for selected active set for making predictions from the
trained gpr model, stored as a logical vector. these indicators mark the
subset of training data that fitrgp
selects as the
active set. for example, if x
is the original
training data, then activesetvectors =
x(isactivesetvector,:)
.
data types: logical
training data
numobservations
— number of observations in training data
scalar value
number of observations in training data, stored as a scalar value.
data types: double
x
— training data
n-by-d table | n-by-d matrix
training data, stored as an
n-by-d table or matrix, where
n is the number of observations and
d is the number of predictor variables (columns)
in the training data. if the gpr model is trained on a table, then
x
is a table. otherwise, x
is
a matrix.
data types: double
| table
y
— observed response values
n-by-1 vector
observed response values used to train the gpr model, stored as an n-by-1 vector, where n is the number of observations.
data types: double
predictornames
— names of predictors
cell array of character vectors
names of predictors used in the gpr model, stored as a cell array of
character vectors. each name (cell) corresponds to a column in
x
.
data types: cell
expandedpredictornames
— names of expanded predictors
cell array of character vectors
names of expanded predictors for the gpr model, stored as a cell array
of character vectors. each name (cell) corresponds to a column in
activesetvectors
.
if the model uses dummy variables for categorical variables, then
expandedpredictornames
includes the names that
describe the expanded variables. otherwise,
expandedpredictornames
is the same as
predictornames
.
data types: cell
responsename
— name of the response variable
character vector
name of the response variable in the gpr model, stored as a character vector.
data types: char
predictorlocation
— means of predictors
1-by-d vector | []
means of predictors used for training the gpr model if the training
data is standardized, stored as a 1-by-d vector. if
the training data is not standardized,
predictorlocation
is empty.
if predictorlocation
is not empty, then the
method centers the
predictor values by subtracting the respective element of
predictorlocation
from every column of
x
.
if there are categorical predictors, then
predictorlocation
includes a 0 for each dummy
variable corresponding to those predictors. the dummy variables are not
centered or scaled.
data types: double
predictorscale
— standard deviations of predictors
1-by-d vector | []
standard deviations of predictors used for training the gpr model if
the training data is standardized, stored as a 1-by-d
vector. if the training data is not standardized,
predictorscale
is empty.
if predictorscale
is not empty, the method scales the
predictors by dividing every column of x
by the
respective element of predictorscale
(after
centering using predictorlocation
).
if there are categorical predictors, then
predictorlocation
includes a 1 for each dummy
variable corresponding to those predictors. the dummy variables are not
centered or scaled.
data types: double
rowsused
— indicators for rows used in training
logical vector | []
indicators for rows used in training the gpr model, stored as a
logical vector. if all rows are used in training the model, then
rowsused
is empty.
data types: logical
object functions
reduce size of machine learning model | |
cross-validate machine learning model | |
lime | local interpretable model-agnostic explanations (lime) |
regression error for gaussian process regression model | |
partialdependence | compute partial dependence |
plotpartialdependence | create partial dependence plot (pdp) and individual conditional expectation (ice) plots |
compute post-fit statistics for the exact gaussian process regression model | |
predict response of gaussian process regression model | |
resubstitution regression loss | |
predict responses for training data using trained regression model | |
shapley | shapley values |
examples
train gpr model and plot predictions
generate sample data.
rng(0,'twister'); % for reproducibility n = 1000; x = linspace(-10,10,n)'; y = 1 x*5e-2 sin(x)./x 0.2*randn(n,1);
fit a gpr model using a linear basis function and the exact fitting method to estimate the parameters. also use the exact prediction method.
gprmdl = fitrgp(x,y,'basis','linear',... 'fitmethod','exact','predictmethod','exact');
predict the response corresponding to the rows of x
(resubstitution predictions) using the trained model.
ypred = resubpredict(gprmdl);
plot the true response with the predicted values.
plot(x,y,'b.'); hold on; plot(x,ypred,'r','linewidth',1.5); xlabel('x'); ylabel('y'); legend('data','gpr predictions'); hold off
more about
active set selection and parameter estimation
for subset of data, subset of regressors, or fully independent conditional
approximation fitting methods (fitmethod
equal to
'sd'
, 'sr'
, or 'fic'
), if you
do not provide the active set (or inducing input set), fitrgp
selects the active set and computes the parameter estimates in a
series of iterations.
in the first iteration, the software uses the initial parameter values in vector η0 = [β0,σ0,θ0] to select an active set a1. it maximizes the gpr marginal log likelihood or its approximation using η0 as the initial values and a1 to compute the new parameter estimates η1. next, it computes the new log likelihood l1 using η1 and a1.
in the second iteration, the software selects the active set a2 using the parameter values in η1. then, using η1 as the initial values and a2, it maximizes the gpr marginal log likelihood or its approximation and estimates the new parameter values η2. then using η2 and a2, computes the new log likelihood value l2.
the following table summarizes the iterations and what is computed at each iteration.
iteration number | active set | parameter vector | log likelihood |
---|---|---|---|
1 | a1 | η1 | l1 |
2 | a2 | η2 | l2 |
3 | a3 | η3 | l3 |
… | … | … | … |
the software iterates similarly for a specified number of repetitions.
you can specify the number of replications for active set selection
using the numactivesetrepeats
name-value
pair argument.
tips
you can access the properties of this class using dot notation. for example,
kernelinformation
is a structure holding the kernel parameters and their names. hence, to access the kernel function parameters of the trained modelgprmdl
, usegprmdl.kernelinformation.kernelparameters
.
extended capabilities
c/c code generation
generate c and c code using matlab® coder™.
usage notes and limitations:
the function supports code generation.
for more information, see introduction to code generation.
version history
introduced in r2015b
see also
fitrgp
| |
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 matlab 命令。
select a web site
choose a web site to get translated content where available and see local events and offers. based on your location, we recommend that you select: .
you can also select a web site from the following list:
how to get best site performance
select the china site (in chinese or english) for best site performance. other mathworks country sites are not optimized for visits from your location.
americas
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)