MATLAB: How to determine which sample was assigned to which node in CLASSREGTREE in Statistics Toolbox 7.4 (R2010b)

Statistics and Machine Learning Toolbox

I would like to determine which sample was assigned to which node in a tree created using CLASSREGTREE.

Best Answer

You can use the EVAL method of the CLASSREGTREE class to determine which sample was assigned to which final node. For example:
load fisheriris;
t = classregtree(meas,species,'names',{'SL' 'SW' 'PL' 'PW'});
[fittedval, nodes] = eval(t,meas); % determine mapping of training samples to nodes
This code stores the nodes for each sample in "meas" in the second output argument "nodes".