Hi David,

I think you should have a look at sklearn.tree.export_graphviz. It
will generate a picture of the tree for you.
- Reference: 
http://scikit-learn.org/dev/modules/generated/sklearn.tree.export_graphviz.html#sklearn.tree.export_graphviz
- Example: http://scikit-learn.org/dev/_images/iris.svg

If you need to inspect the tree yourself, have a look at the
implementation of export_graphviz.
- 
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/tree.py#L48

Hope this helps,

Gilles

On 27 February 2013 08:19, David Montgomery <[email protected]> wrote:
> Hi,
>
> I will be using a tree.  All dependent variables are categorical ordinal.
>
> For each leaf node. I need to get the node id and a list of all attributes
> that make up the path to the leaf node.  E.g.
>
>
> root_node
>       GEO:
>             NewYork
>             Boston,Philly
>              BOSTON:PHILLY->TIME:
>                         1PM
>                          2PM
>
>
> The above is one path where the leaf node is TIME.  The distinct rules that
> make up the path are as follows
>
> Geo:[Boston:Philly]->Time:[1pm,2pm]
>
>
>
>
>
>  How to I access the tree object so I can write code to get the keys and
> values of each node that comprises a leaf node path?
>
> e.g.
>
> clf = tree.DecisionTreeRegressor()
> clf = clf.fit(iris.data, iris.target)
> mytree = clf.WHAT?
>
> Thanks
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to