access to path produced by train mehtod

asked 2014-01-23 07:07:58 -0500

jossyy gravatar image

Hello,

I am using random trees. Sometimes I encounter that I dont expect the result of predict function.

So I want to see content of trees. I know CvRTrees::get_tree_count() and CvForestTree* CvRTrees::get_tree(int i). I dont know how can I see the classcifiar path

edit retag flag offensive close merge delete

Comments

Try saving the random forest out to an xml/yaml file. It won't be pretty to process manually by hand but it's do-able, at least for a single tree.

Nghia gravatar imageNghia ( 2014-01-24 03:34:41 -0500 )edit

How can I understand this xml file ? My output is below , which attribute says it's right and left node , or it's response value...

<nodes><_><depth>0</depth><sample_count>314</sample_count><value>-1.</value><norm_class_idx>0</norm_class_idx><Tn>0</Tn><complexity>0</complexity><alpha>0.</alpha><node_risk>24.</node_risk><tree_risk>0.</tree_risk><tree_error>0.</tree_error><splits><_><var>0</var><quality>2.7262069702148438e+02</quality><le>0.</le></_></splits></_><_>

jossyy gravatar imagejossyy ( 2014-01-24 06:24:55 -0500 )edit

I'm a bit more familiar with the YAML format, but the important info to look for are: depth (tree depth), var (feature used to split on, index to your array), le (less than or equal), value (the value it is comparing to). If the current value is "less than or equal" to "value" the it branches left, else right. Helps to sketch it on paper.

Nghia gravatar imageNghia ( 2014-01-24 07:04:17 -0500 )edit

ok , thanks for your helps..

jossyy gravatar imagejossyy ( 2014-01-25 11:16:10 -0500 )edit