support vector machine regression model -凯发k8网页登录
superclasses: compactregressionsvm
support vector machine regression model
description
regressionsvm
is a support vector machine (svm) regression model. train a regressionsvm
model using fitrsvm
and the sample data.
regressionsvm
models store data, parameter values, support vectors, and algorithmic implementation information. you can use these models to:
estimate resubstitution predictions. for details, see .
predict values for new data. for details, see .
compute resubstitution loss. for details, see .
compute the mean square error or epsilon-insensitive loss. for details, see .
construction
create a regressionsvm
object by using fitrsvm
.
properties
alpha
— dual problem coefficients
vector of numeric values
dual problem coefficients, specified as a vector of numeric values. alpha
contains m elements, where m is the number of
support vectors in the trained svm regression model. the dual problem introduces two
lagrange multipliers for each support vector. the values of alpha
are
the differences between the two estimated lagrange multipliers for the support vectors.
for more details, see .
if you specified to remove duplicates using removeduplicates
,
then, for a particular set of duplicate observations that are support vectors,
alpha
contains one coefficient corresponding to the entire set.
that is, matlab® attributes a nonzero coefficient to one observation from the set of
duplicates and a coefficient of 0
to all other duplicate observations
in the set.
data types: single
| double
beta
— primal linear problem coefficients
vector of numeric values | '[]'
primal linear problem coefficients, stored as a numeric vector of length p, where p is the number of predictors in the svm regression model.
the values in beta
are the linear coefficients for the primal optimization problem.
if the model is obtained using a kernel function other than 'linear'
, this property is empty ('[]'
).
the method computes predicted response values for the model as yfit = (x/s)×beta bias
, where s
is the value of the kernel scale stored in the kernelparameters.scale
property.
data types: single
| double
bias
— bias term
scalar value
bias term in the svm regression model, stored as a scalar value.
data types: single
| double
boxconstraints
— box constraints for dual problem coefficients
vector of numeric values
box constraints for dual problem alpha coefficients, stored as a numeric vector containing n elements, where n is the number of observations in x
(mdl.numobservations
).
the absolute value of the dual coefficient alpha
for observation i cannot exceed boxconstraints(i)
.
if you specify removing duplicates using 'removeduplicates'
, then for a given set of duplicate observations, matlab sums the box constraints, and then attributes the sum to one observation and box constraints of 0
to all other observations in the set.
data types: single
| double
cacheinfo
— caching information
structure
caching information, stored as a structure with the following fields.
field | description |
---|---|
'size' | positive scalar value indicating the cache size (in mb) that the software reserves to store entries of the gram matrix. set the cache size by using the 'cachesize' name-value pair argument in fitrsvm . |
'algorithm' | character vector containing the name of the algorithm used to remove entries from the cache when its capacity is exceeded. currently, the only available caching algorithm is 'queue' . you cannot set the caching algorithm. |
data types: struct
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
convergenceinfo
— convergence information
structure
convergence information, stored as a structure with the following fields.
field | description |
---|---|
converged | logical flag indicating whether the algorithm converged. a value of 1 indicates convergence. |
reasonforconvergence | character vector indicating the criterion the software used to detect convergence. |
gap | scalar feasibility gap between the dual and primal objective functions. |
gaptolerance | scalar tolerance for the feasibility gap. you can set this tolerance using the 'gaptolerance' name-value pair argument in fitrsvm . |
deltagradient | scalar gradient difference between upper and lower violators. |
deltagradienttolerance | scalar tolerance for the gradient difference. you can set this tolerance using the deltagradienttolerance name-value pair argument in fitrsvm . |
largestkktviolation | maximal scalar karush-kuhn-tucker (kkt) violation value. |
kkttolerance | scalar tolerance for the largest kkt violation. you can set this tolerance using the 'kkttolerance' name-value pair argument in fitrsvm . |
history | structure containing convergence information recorded at periodic intervals during the model training process. this structure contains the following fields:
|
objective | numeric value of the dual objective. |
data types: struct
epsilon
— half the width of the epsilon-insensitive band
nonnegative scalar value
half the width of the epsilon-insensitive band, stored as a nonnegative scalar value.
data types: single
| double
expandedpredictornames
— expanded predictor names
cell array of character vectors
expanded predictor names, stored 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
gradient
— gradient values in training data
vector of numeric values
gradient values in training data, stored as a numeric vector containing 2n elements, where n is the number of observations in the training data.
element i of gradient
contains the gradient value for the alpha
coefficient that corresponds to the upper boundary of the epsilon-insensitive band at observation i at the end of the optimization.
element i numobservations of gradient
contains the gradient value for the alpha
coefficient that corresponds to the lower boundary of the epsilon-insensitive band at observation i at the end of the optimization.
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) |
issupportvector
— flag indicating whether observation is support vector
logical vector
flag indicating whether an observation is a support vector, stored as an n-by-1 logical vector. n is the number of observations in x
(see numobservations
). a value of 1
indicates that the corresponding observation in the training data is a support vector.
if you specify removing duplicates using removeduplicates
, then for a given set of duplicate observations that are support vectors, issupportvector
flags only one as a support vector.
data types: logical
kernelparameters
— kernel function parameters
structure
kernel function parameters, stored as a structure with the following fields.
field | description |
---|---|
function
| kernel function name (a character vector). |
scale | numeric scale factor used to divide predictor values. |
you can specify values for kernelparameters.function
and kernelparameters.scale
by using the kernelfunction
and kernelscale
name-value pair arguments in fitrsvm
, respectively.
data types: struct
modelparameters
— parameter values
model parameter object
parameter values used to train the svm regression model, stored as a model parameter object. access the properties of modelparameters
using dot notation. for example, access the value of epsilon
used to train the model as mdl.modelparameters.epsilon
.
mu
— predictor means
vector of numeric values | '[]'
predictor means, stored as a vector of numeric values.
if the predictors are standardized, then mu
is a numeric vector of length p, where p is the number of predictors used to train the model. in this case, the method centers predictor matrix x
by subtracting the corresponding element of mu
from each column.
if the predictors are not standardized, then mu
is empty ('[]'
).
if the data contains categorical predictors, then mu
includes elements for the dummy variables for those predictors. the corresponding entries in mu
are 0 because dummy variables are not centered or scaled.
data types: single
| double
numiterations
— number of iterations required for convergence
positive integer value
number of iterations required for the optimization routine to reach convergence, stored as a positive integer value.
to set a limit on the number of iterations, use the 'iterationlimit'
name-value pair argument of fitrsvm
.
data types: single
| double
numobservations
— number of observations
positive integer value
number of observations in the training data, stored as a positive integer value.
data types: single
| double
predictornames
— predictor names
cell array of character vectors
predictor names, stored as a cell array of character vectors containing the name of each predictor in the order they appear in x
. predictornames
has a length equal to the number of columns in x
.
data types: cell
outlierfraction
— expected fraction of outliers
scalar value in the range [0,1]
expected fraction of outliers in the training set, stored as a scalar value in the range [0,1]. you can specify the expected fraction of outliers using the 'outlierfraction'
name-value pair argument in fitrsvm
.
data types: double
responsename
— response variable name
character vector
response variable name, stored as a character vector.
data types: char
responsetransform
— response transformation function
'none'
| function handle
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
| function_handle
shrinkageperiod
— number of iterations between reductions of active set
nonnegative integer value
number of iterations between reductions of the active set during optimization, stored as a nonnegative integer value.
you can set the shrinkage period by using the 'shrinkageperiod'
name-value pair argument in fitrsvm
.
data types: single
| double
sigma
— predictor standard deviations
vector of numeric values | '[]'
predictor standard deviations, stored as a vector of numeric values.
if the predictors are standardized, then sigma
is a numeric vector of length p, where p is the number of predictors used to train the model. in this case, the method scales the predictor matrix x
by dividing each column by the corresponding element of sigma
, after centering each element using mu
.
if the predictors are not standardized, then sigma
is empty ('[]'
).
if the data contains categorical predictors, sigma
includes elements for the dummy variables for those predictors. the corresponding entries in sigma
are 1, because dummy variables are not centered or scaled.
data types: single
| double
solver
— name of solver algorithm
character vector
name of the solver algorithm used to solve the optimization problem, stored as a value in this table.
value | description |
---|---|
'smo' | sequential minimal optimization |
'isda' | iterative single data algorithm |
'l1qp' | l1 soft-margin minimization by quadratic programming (requires an optimization toolbox™ license). |
supportvectors
— support vectors
matrix of numeric values
support vectors, stored as an m-by-p matrix
of numeric values. m is the number of support vectors
(sum(mdl.issupportvector)
), and p is
the number of predictors in x
.
if you specified to remove duplicates using removeduplicates
,
then for a given set of duplicate observations that are support vectors,
supportvectors
contains one unique support vector.
data types: single
| double
w
— observation weights
vector of numeric values
observation weights used to train the model, stored as a numeric vector containing numobservation
number of elements. fitrsvm
normalizes the weights used for training so that they sum to 1.
data types: single
| double
x
— predictor values
matrix of numeric values | table of numeric values
predictor values used to train the model, stored as a matrix of numeric values if the model is trained on a matrix, or a table if the model is trained on a table. x
has size n-by-p, where n is the number of rows and p is the number of predictor variables or columns in the training data.
data types: single
| double
| table
y
— observed response values
vector of numeric values
observed response values, stored as a numeric vector containing numobservations
number of elements.
data types: single
| double
object functions
compact support vector machine regression model | |
cross-validated support vector machine regression model | |
discardsupportvectors | discard support vectors for linear support vector machine (svm) regression model |
gather properties of statistics and machine learning toolbox object from gpu | |
convert support vector machine (svm) regression model to incremental learner | |
lime | local interpretable model-agnostic explanations (lime) |
regression error for support vector machine regression model | |
partialdependence | compute partial dependence |
plotpartialdependence | create partial dependence plot (pdp) and individual conditional expectation (ice) plots |
predict responses using support vector machine regression model | |
resubstitution loss for support vector machine regression model | |
predict resubstitution response of support vector machine regression model | |
resume training support vector machine regression model | |
shapley | shapley values |
copy semantics
value. to learn how value classes affect copy operations, see .
examples
train linear support vector machine regression model
this example shows how to train a linear support vector machine (svm) regression model using sample data stored in matrices.
load the carsmall
data set.
load carsmall rng default % for reproducibility
specify horsepower
and weight
as the predictor variables (x
) and mpg
as the response variable (y
).
x = [horsepower,weight]; y = mpg;
train a linear svm regression model.
mdl = fitrsvm(x,y)
mdl = regressionsvm responsename: 'y' categoricalpredictors: [] responsetransform: 'none' alpha: [75x1 double] bias: 57.3800 kernelparameters: [1x1 struct] numobservations: 93 boxconstraints: [93x1 double] convergenceinfo: [1x1 struct] issupportvector: [93x1 logical] solver: 'smo' properties, methods
the command window shows that mdl
is a trained regressionsvm
model and a list of its properties.
check the model for convergence.
mdl.convergenceinfo.converged
ans = logical
0
0
indicates that the model did not converge.
mdlstd = fitrsvm(x,y,'standardize',true)
mdlstd = regressionsvm responsename: 'y' categoricalpredictors: [] responsetransform: 'none' alpha: [77x1 double] bias: 22.9131 kernelparameters: [1x1 struct] mu: [109.3441 2.9625e 03] sigma: [45.3545 805.9668] numobservations: 93 boxconstraints: [93x1 double] convergenceinfo: [1x1 struct] issupportvector: [93x1 logical] solver: 'smo' properties, methods
check the model for convergence.
mdlstd.convergenceinfo.converged
ans = logical
1
1
indicates that the model did converge.
compute the resubstitution mean squared error for the new model.
lstd = resubloss(mdlstd)
lstd = 17.0256
train support vector machine regression model
train a support vector machine regression model using the abalone data from the uci machine learning repository.
download the data and save it in your current folder with the name 'abalone.csv'
.
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data'; websave('abalone.csv',url);
read the data into a table. specify the variable names.
varnames = {'sex'; 'length'; 'diameter'; 'height'; 'whole_weight';... 'shucked_weight'; 'viscera_weight'; 'shell_weight'; 'rings'}; tbl = readtable('abalone.csv','filetype','text','readvariablenames',false); tbl.properties.variablenames = varnames;
the sample data contains 4177 observations. all the predictor variables are continuous except for sex
, which is a categorical variable with possible values 'm'
(for males), 'f'
(for females), and 'i'
(for infants). the goal is to predict the number of rings (stored in rings
) on the abalone and determine its age using physical measurements.
train an svm regression model, using a gaussian kernel function with an automatic kernel scale. standardize the data.
rng default % for reproducibility mdl = fitrsvm(tbl,'rings','kernelfunction','gaussian','kernelscale','auto',... 'standardize',true)
mdl = regressionsvm predictornames: {'sex' 'length' 'diameter' 'height' 'whole_weight' 'shucked_weight' 'viscera_weight' 'shell_weight'} responsename: 'rings' categoricalpredictors: 1 responsetransform: 'none' alpha: [3635×1 double] bias: 10.8144 kernelparameters: [1×1 struct] mu: [0 0 0 0.5240 0.4079 0.1395 0.8287 0.3594 0.1806 0.2388] sigma: [1 1 1 0.1201 0.0992 0.0418 0.4904 0.2220 0.1096 0.1392] numobservations: 4177 boxconstraints: [4177×1 double] convergenceinfo: [1×1 struct] issupportvector: [4177×1 logical] solver: 'smo' properties, methods
the command window shows that mdl
is a trained regressionsvm
model and displays a property list.
display the properties of mdl
using dot notation. for example, check to confirm whether the model converged and how many iterations it completed.
conv = mdl.convergenceinfo.converged
conv = logical
1
iter = mdl.numiterations
iter = 2759
the returned results indicate that the model converged after 2759 iterations.
references
[1] nash, w.j., t. l. sellers, s. r. talbot, a. j. cawthorn, and w. b. ford. "the population biology of abalone (haliotis species) in tasmania. i. blacklip abalone (h. rubra) from the north coast and islands of bass strait." sea fisheries division, technical report no. 48, 1994.
[2] waugh, s. "extending and benchmarking cascade-correlation: extensions to the cascade-correlation architecture and benchmarking of feed-forward supervised artificial neural networks." university of tasmania department of computer science thesis, 1995.
[3] clark, d., z. schreter, a. adams. "a quantitative comparison of dystal and backpropagation." submitted to the australian conference on neural networks, 1996.
[4] lichman, m. uci machine learning repository, [http://archive.ics.uci.edu/ml]. irvine, ca: university of california, school of information and computer science.
extended capabilities
c/c code generation
generate c and c code using matlab® coder™.
usage notes and limitations:
the and
update
functions support code generation.
to integrate the prediction of an svm regression model into simulink®, you can use the block in the statistics and machine learning toolbox™ library or a matlab function block with the
predict
function.when you train an svm regression model by using
fitrsvm
, the following restrictions apply.the value of the
responsetransform
name-value argument cannot be an anonymous function. for fixed-point code generation, the value must be'none'
(default).for fixed-point code generation, the value of the
kernelfunction
name-value argument must be'gaussian'
,'linear'
, or'polynomial'
.fixed-point code generation and code generation with a coder configurer do not support categorical predictors (
logical
,categorical
,char
,string
, orcell
). you cannot use thecategoricalpredictors
name-value argument. to include categorical predictors in a model, preprocess them by using before fitting the model.
for more information, see introduction to code generation.
gpu arrays
accelerate code by running on a graphics processing unit (gpu) using parallel computing toolbox™.
usage notes and limitations:
the following object functions fully support gpu arrays:
the object functions execute on a gpu if any of the following apply:
the model was fitted with gpu arrays.
the predictor data that you pass to the object function is a gpu array.
the response data that you pass to the object function is a gpu array.
for more information, see run matlab functions on a gpu (parallel computing toolbox).
version history
introduced in r2015br2023a: gpu array support for object functions (requires parallel computing toolbox)
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
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)
- 中国
- (日本語)
- (한국어)