Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How does predict work for classification tree algorithm?

Asked by Hadas Lapid

Hadas Lapid (view profile)

on 14 Nov 2013
Latest activity Answered by Hadas Lapid

Hadas Lapid (view profile)

on 17 Nov 2013

Following classification with ClassificationTree.fit I get an object obj which contains all model parameters. Then when using predict(data,model) I try it on new data. Question is that I need to translate the predict code into human language, in order to transform it into c code. The code does Not support predict. Can anyone direct me to the full algorithm predict performs? (I couldn't figure it out from predict.m directly..) Many many thanks Hadas

0 Comments

Hadas Lapid

Hadas Lapid (view profile)

2 Answers

Answer by Shashank Prasanna

Shashank Prasanna (view profile)

on 14 Nov 2013
Edited by Shashank Prasanna

Shashank Prasanna (view profile)

on 14 Nov 2013
Accepted answer

Type:

>> view(obj)

you can visualize the tree.

predict generates predictions by following the branches of tree until it reaches a leaf node or a missing value. If predict reaches a leaf node, it returns the classification of that node.

This information is also available in the documentation, scroll down to Algorithm section:

http://www.mathworks.com/help/stats/compactclassificationtree.predict.html

Also here is some theory that you may find useful:

http://www.mathworks.com/help/stats/classification-trees-and-regression-trees.html#bsw6a62

0 Comments

Shashank Prasanna

Shashank Prasanna (view profile)

Answer by Hadas Lapid

Hadas Lapid (view profile)

on 17 Nov 2013

view(tree) was exactly what I needed, thank you!

0 Comments

Hadas Lapid

Hadas Lapid (view profile)

Contact us