Defining cost function in partitioned SVM model
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm trying to train an SVM using leave one out cross validation with a cost function that takes into account the prior probabilities for each class. The version I'm working with is R2014a.
First, I set up a partitioning scheme as follows:
c = cvpartition(outcomeVar,'LeaveOut');
Then, I set up a cost function:
costFcn = [0 1; 1.4545 0];
Then I define the model.
mdl = fitcsvm(predictorDat,outcomeVar,'CVPartition',c,'KernelFunction','Polynomial','PolynomialOrder',3,'KernelScale',KS, ...
'BoxConstraint',BC,'KKTTolerance',.001,'Cost',costFcn,'ClassNames',CNames)
Now, when I look at the model parameters I find that the cost function is not the one that I defined.
mdl.Cost
ans =
0 1
1 0
Furthermore, if I look at one of the partitions I see the same.
mdl.Trained{1}.Cost
ans =
0 1
1 0
When I look at the priors of the model, they seem to be adjusted according to the cost function I initially defined.
So, my question is: does Matlab update the the priors and reset the cost function to the default as an equivalent operation to leaving the cost function as I define it and setting the priors to be equivalent to the observed class frequencies?
Furthermore, is there a reason why the kfoldLoss returned in individual mode is ordered according to the partitioning scheme, whereas the kfoldMargin is returned according to the order of the input data?
0 comentarios
Respuestas (1)
Ilya
el 28 de Jul. de 2015
So, my question is: does Matlab update the the priors and reset the cost function to the default as an equivalent operation to leaving the cost function as I define it and setting the priors to be equivalent to the observed class frequencies?
Yes.
Furthermore, is there a reason why the kfoldLoss returned in individual mode is ordered according to the partitioning scheme, whereas the kfoldMargin is returned according to the order of the input data?
Loss is defined per dataset; there is one loss value for each cross-validation fold. Margin is defined for each observation; there are always as many margins as there are observations. Loss values are always ordered by folds, and margins are always ordered by observations.
2 comentarios
Ver también
Categorías
Más información sobre Classification Trees en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!