How can i use Random Forest classifier ?
145 views (last 30 days)
Show older comments
I know that sounds stupid but im very very very new to matlab and i have a homework to do. Basicly i searched whole internet to find out for a basic example of using Random Forest. https://ch.mathworks.com/help/stats/treebagger.html#bvf7_tc-1 this one helped me a little but im still confused about the usage. I understand that i need to use NumPredictorsToSample but how ? can somebody please show me a VERY simple syntax and show me which piece of code does what. Im very desperate.
0 Comments
Answers (1)
zineb kaoudja
on 6 Aug 2019
%Tr is the training samples
%cl1 is the class label for the training images
%Ts is the testing samples
%cl2 is the class label for the test images
nTrees=500;
B = TreeBagger(nTrees,Tr,cl1, 'Method', 'classification');
predChar1 = B.predict(Ts); % Predictions is a char though. We want it to be a number.
c = str2double(predChar1);
consistency=sum(c==cl2)/length(cl2);
See Also
Categories
Find more on Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!