Hi Caleb,
you need to extract the path from the decision tree structure
``DecisionTreeClassifier.tree_`` - take a look at the attributes
``children_left`` and ``children_right`` - these encode the parent-child
relationship.
Extracting the path is very similar to finding the leaf node; you just need
to keep track of what choices you made along the way - just modify
``sklearn.tree._tree.Tree.apply`` [1] accordingly.
best,
Peter
[1]
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx#L1907
2013/12/8 Caleb <[email protected]>
> Hi everyone,
>
> Given an instance (x_1,x_2,...,x_n), I want to know what about it that
> make the decision tree belong to certain class, ie: x_1 < a, x_3> b,.....
> => x is of class C.
>
> I notice that .apply can return the id of the leaf node that the instance
> falls in, but can I get the path from the root node down to this leaf node?
>
> Any idea?
>
> -
> Caleb
>
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
>
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
--
Peter Prettenhofer
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general