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

    %% Fit the Score-to-Posterior Probability Function for Inseparable Classes
%%
% Load the |ionosphere| data set.

% Copyright 2015 The MathWorks, Inc.

load ionosphere
%%
% The classes of this data set are not separable.
%%
% Train an SVM classifier.  Cross validate using 10-fold cross validation
% (the default). It is good practice to standardize the predictors and
% specify the class order.
rng(1) % For reproducibility
CVSVMModel = fitcsvm(X,Y,'ClassNames',{'b','g'},'Standardize',true,...
    'CrossVal','on');
ScoreTransform = CVSVMModel.ScoreTransform
%%
% |CVSVMModel| is a trained |ClassificationPartitionedModel| SVM classifier.
% The positive class is |'g'|. The |ScoreTransform| property is |none|.
%%
% Estimate the optimal score function for mapping observation scores to
% posterior probabilities of an observation being classified as |'g'|.
[ScoreCVSVMModel,ScoreParameters] = fitSVMPosterior(CVSVMModel);
ScoreTransform = ScoreCVSVMModel.ScoreTransform
ScoreParameters
%%
% |ScoreTransform| is the optimal score transform function.
% |ScoreParameters| contains the score transformation function, slope
% estimate, and the intercept estimate.
%%
% You can estimate test-sample, posterior probabilities by passing
% |ScoreCVSVMModel| to |kfoldPredict|.