Random Forest model, CQI
조회 수: 6 (최근 30일)
이전 댓글 표시
HI, I would like to evaluate the accuracy of a Random Forest model and visualize the confusion matrix in the CQI class prediction context. Any ideas?
댓글 수: 0
답변 (1개)
Gayathri
2025년 6월 2일
To evaluate the accuracy and the confusion matrix of a random forest model, we can use the below code.
load census1994
Mdl1 = fitcensemble(adultdata,'salary')
rng(1) % For reproducibility
[pX,pIdx] = datasample(adultdata,5);
label = predict(Mdl1,pX);
% To calculate accuracy
accuracy = mean(label == adultdata.salary(pIdx))
% confusion chart
cm = confusionchart(label, adultdata.salary(pIdx));
The data and code used for illustration can be obtained by running the following command from the Command Window.
openExample('stats/EstimateResubstitutionLossOfBoostingEnsembleExample')
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Discriminant Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!