Why does the cost property of my ensemble model object revert to default when I changed the value?

3 views (last 30 days)
I am training an ensemble of classification trees, and I want to specify a unique cost matrix because there are unequal classification costs.
I ran the 'fitcensemble' function with the 'Cost' name value pair argument. I set the cost matrix to [0 50; 5 0]. However, when I look at my resulting ensemble model returned by this function, the 'Cost' field has reverted to the default matrix [0 1; 1 0]. Why is this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Mar 2019
See the documentation for 'fitcensemble':
And the following link about handling unequal misclassification costs:
There are two properties for ensemble models that are used to handle imbalanced data or unequal misclassification costs, 'Cost' and 'Prior'. 'Cost' describes the misclassification costs for each class, and 'Prior' describes the prior probability of each class.
In the description of the 'Cost' property, there is a note that says:
"'fitcensemble' uses 'Cost' to adjust the prior class probabilities specified in 'Prior'. Then, 'fitcensemble' uses the adjusted prior probabilities for training and resets the cost matrix to its default."
This is why the cost might revert to the default matrix, [0 1; 1 0], after fitting a model with a different specified cost. The 'Prior' property has been adjusted to train the model according to these new misclassification costs, and the 'Cost' field has returned to its default value.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!