fitSVMPosterior
Fit posterior probabilities
Syntax
Description
returns ScoreSVMModel
= fitSVMPosterior(SVMModel
)ScoreSVMModel
,
which is a trained, support vector machine (SVM) classifier containing
the optimal score-to-posterior-probability transformation function
for two-class learning.
The software fits the appropriate score-to-posterior-probability transformation function using
the SVM classifier SVMModel
, and by cross validation using
the stored predictor data (SVMModel.X
) and the class labels
(SVMModel.Y
). The transformation function computes the
posterior probability that an observation is classified into the positive class
(SVMModel.Classnames(2)
).
If the classes are inseparable, then the transformation function is the sigmoid function.
If the classes are perfectly separable, the transformation function is the step function.
In two-class learning, if one of the two classes has a relative frequency of 0, then the transformation function is the constant function.
fitSVMPosterior
is not appropriate for one-class learning.If
SVMModel
is aClassificationSVM
classifier, then the software estimates the optimal transformation function by 10-fold cross validation as outlined in [1]. Otherwise,SVMModel
must be aClassificationPartitionedModel
classifier.SVMModel
specifies the cross-validation method.The software stores the optimal transformation function in
ScoreSVMModel.ScoreTransform
.
returns a trained support vector classifier containing the transformation
function from the trained, compact SVM classifier ScoreSVMModel
= fitSVMPosterior(SVMModel
,Tbl
,ResponseVarName
)SVMModel
.
The software estimates the score transformation function using predictor data in
the table Tbl
and class labels
Tbl.ResponseVarName
.
returns a trained support vector classifier containing the transformation
function from the trained, compact SVM classifier ScoreSVMModel
= fitSVMPosterior(SVMModel
,Tbl
,Y
)SVMModel
.
The software estimates the score transformation function using predictor data in
the table Tbl
and class labels
Y
.
returns
a trained support vector classifier containing the transformation
function from the trained, compact SVM classifier ScoreSVMModel
= fitSVMPosterior(SVMModel
,X
,Y
)SVMModel
.
The software estimates the score transformation function using predictor
data X
and class labels Y
.
uses
additional options specified by one or more ScoreSVMModel
= fitSVMPosterior(___,Name,Value
)Name,Value
pair
arguments provided SVMModel
is a ClassificationSVM
classifier.
For example, you can specify the number of folds to use in k-fold
cross validation.
[
additionally returns
the transformation function parameters (ScoreSVMModel
,ScoreTransform
]
= fitSVMPosterior(___)ScoreTransform
)
using any of the input arguments in the previous syntaxes.
Examples
Input Arguments
Output Arguments
More About
Tips
This process describes one way to predict positive class posterior probabilities.
Train an SVM classifier by passing the data to
fitcsvm
. The result is a trained SVM classifier, such asSVMModel
, that stores the data. The software sets the score transformation function property (SVMModel.ScoreTransformation
) tonone
.Pass the trained SVM classifier
SVMModel
tofitSVMPosterior
orfitPosterior
. The result, such as,ScoreSVMModel
, is the same trained SVM classifier asSVMModel
, except the software setsScoreSVMModel.ScoreTransformation
to the optimal score transformation function.Pass the predictor data matrix and the trained SVM classifier containing the optimal score transformation function (
ScoreSVMModel
) topredict
. The second column in the second output argument ofpredict
stores the positive class posterior probabilities corresponding to each row of the predictor data matrix.If you skip step 2, then
predict
returns the positive class score rather than the positive class posterior probability.
After fitting posterior probabilities, you can generate C/C++ code that predicts labels for new data. Generating C/C++ code requires MATLAB® Coder™. For details, see Introduction to Code Generation.
Algorithms
If you re-estimate the score-to-posterior-probability
transformation function, that is, if you pass an SVM classifier to
fitPosterior
or fitSVMPosterior
and its
ScoreTransform
property is not none
, then the software:
Displays a warning
Resets the original transformation function to
'none'
before estimating the new one
References
[1] Platt, J. “Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods”. In: Advances in Large Margin Classifiers. Cambridge, MA: The MIT Press, 2000, pp. 61–74.
Version History
Introduced in R2014a