2012/11/12  <[email protected]>:
>
> Dear SciKitters,
>
> given an array of (n_samples,n_features) -> How do I assign target_names in
> a concluding step?
>
> The target_names are stored in a list and, of course, have the same order
> as the n_features vector.
>
> In a next step, I would like to dump out the importance of the most
> relevant features? How can this be done in scikit-learn? In particular, I
> have trained a random forest and would like to dump out the leaves of this
> RF.

Hi Paul,

this example shows how to access the feature importance computed by a RF::

http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html#example-ensemble-plot-forest-importances-py

in order to access the ``feature_importances_`` attribute you have to
use the following argument ``compute_importances=True`` .

To access the leaves of a decision tree you need to access the
``tree_`` attribute of a DecisionTree - it is basically a collection
of parallel arrays that represent the tree (see sklearn.tree._tree).
All indices where ``children_left`` and ``children_right`` is -1 are
leaves.

best,
 Peter


>
>
> Cheers & Thanks,
> Paul
>
> This message and any attachment are confidential and may be privileged or
> otherwise protected from disclosure. If you are not the intended recipient,
> you must not copy this message or attachment or disclose the contents to
> any other person. If you have received this transmission in error, please
> notify the sender immediately and delete the message and any attachment
> from your system. Merck KGaA, Darmstadt, Germany and any of its
> subsidiaries do not accept liability for any omissions or errors in this
> message which may arise as a result of E-Mail-transmission or for damages
> resulting from any unauthorized changes of the content of this message and
> any attachment thereto. Merck KGaA, Darmstadt, Germany and any of its
> subsidiaries do not guarantee that this message is free of viruses and does
> not accept liability for any damages caused by any virus transmitted
> therewith.
>
> Click http://www.merckgroup.com/disclaimer to access the German, French,
> Spanish and Portuguese versions of this disclaimer.
>
>
> ------------------------------------------------------------------------------
> 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_nov
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general



-- 
Peter Prettenhofer

------------------------------------------------------------------------------
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_nov
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to