www.gusucode.com > stats 源码程序 matlab案例代码 > stats/TrainLinearSupportVectorMachineRegressionModelExample.m

    %% Train Linear Support Vector Machine Regression Model
% Train a 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 default SVM regression model.
Mdl = fitrsvm(X,Y)
%%
% |Mdl| is a trained |RegressionSVM| model.
%%
% Check the model for convergence.
Mdl.ConvergenceInfo.Converged
%%
% |0| indicates that the model did not converge.
%%
% Retrain the model using standardized data.
MdlStd = fitrsvm(X,Y,'Standardize',true)
%%
% Check the model for convergence.
MdlStd.ConvergenceInfo.Converged
%%
% |1| indicates that the model did converge.
%%
% Compute the resubstitution (in-sample) mean-squared error for the new model.
lStd = resubLoss(MdlStd)