- https://www.mathworks.com/help/stats/regressiontree.resubloss.html
- https://www.mathworks.com/help/stats/classificationsvm.resubloss.html
how to set up error function other than MSE in regression or classification training model
조회 수: 2 (최근 30일)
이전 댓글 표시
when training a regression tree or SVM model, the default error function is MSE. How do I change it to a customized function more suitable to my application? I didn't find such an option parameter in fitrensemble or fitrsvm function.
댓글 수: 0
답변 (1개)
Brahmadev
2023년 9월 12일
Hi Jie,
I understand that you would like to use a custom error function in Regression Tree and Support Vector Machines. You can use the "resubLoss" function for the same. The "LossFun" parameter is used for defining the custom error function using the syntax below.
L= resubLoss(tree,'Subtrees',subtreevector,'LossFun','lossfun') % for RegressionTree
L = resubLoss(Mdl,'LossFun','lossfun') % for SVM
Here, “lossfun” is a custom loss function with the following function definition
function loss = lossfun(Y,Yfit,W) % for RegressionTree
% Y is an N-element vector representing the observed response.
% Yfit is an N-element vector representing the predicted responses.
% W is an N-element vector representing the observation weights.
% The output loss should be a scalar.
function lossvalue = lossfun(C,S,W,Cost) % for SVM
% C is an n-by-K logical matrix with rows indicating the class to which the corresponding observation belongs.
% S is an n-by-K numeric matrix of classification scores.
% W is an n-by-1 numeric vector of observation weights.
% Cost is a K-by-K numeric matrix of misclassification costs.
In addition to building custom function for error calculation, "Classification Learner" App also provides many inbuilt loss functions such as Binomial deviance, Quadratic loss, Logit loss, Hinge loss and many more.
You can refer to the MathWorks Documentation of “resubLoss” using the links below for more information:
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!