[scikit-learn] tree visualization with class names in leaves
Startup Hire
blrstartuphire at gmail.com
Tue Oct 25 02:41:08 EDT 2016
Hi all,
Thanks for the suggestion.
I have a related question on tree visualization
I have 2 classes to predict: 0 and 1 (it comes up as a numeric field when I
load the dataset)
I have given the class_names as "NotPresent" and "Ispresent" which I
believe it will map to 0 and 1. is that correct?
How do I interpret the nodes and value present in each nodes in the
accompanying diagram?
Regards,
Sanant
On Mon, Oct 24, 2016 at 9:17 PM, Sebastian Raschka <se.raschka at gmail.com>
wrote:
> Hi, Greg,
> if you provide the `class_names` argument, a “class” label of the majority
> class will be added at the bottom of each node. For instance, if you have
> the Iris dataset, with class labels 0, 1, 2, you can provide the
> `class_names` as ['setosa', 'versicolor', 'virginica’], where 0 ->
> ‘setosa’, 1 -> ‘versicolor’, 2 -> ‘virginica’.
>
> Best,
> Sebastian
>
> > On Oct 24, 2016, at 10:18 AM, greg g <greg315 at hotmail.fr> wrote:
> >
> > bLaf1ox-forefront-antispam-report: EFV:NLI; SFV:NSPM;
> SFS:(10019020)(98900003);
> > DIR:OUT; SFP:1102; SCL:1; SRVR:DB5EUR03HT168;
> > H:DB3PR04MB0780.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en;
> > x-ms-office365-filtering-correlation-id: 319900b9-973c-49bb-8e9a-
> 08d3fc1895c4
> > x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
> > RULEID:(1601124038)(1603103081)(1601125047); SRVR:DB5EUR03HT168;
> > x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
> > RULEID:(432015012)(82015046); SRVR:DB5EUR03HT168; BCL:0; PCL:0; RULEID:;
> > SRVR:DB5EUR03HT168;
> > x-forefront-prvs: 0105DAA385
> > X-OriginatorOrg: outlook.com
> > X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Oct 2016
> 14:18:11.0102 (UTC)
> > X-MS-Exchange-CrossTenant-fromentityheader: Internet
> > X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
> > X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT168
> >
> >
> > Hi,
> > I just begin with scikit-learn and would like to visualize a
> classification tree with class names displayed in the leaves as shown in
> the SCIKITLEARN.TREE documentation http://scikit-learn.org/
> stable/modules/tree.html where we find class=’virginica’ etc…
> > I made a tree providing a 2D array X (n1 samples , n2 features) and 1D
> array Y (n1 corresponding classes ) such that Y(i) is the class of the
> sample X(i, …)
> > After that I have correct predictions using predict()
> > Then I use the function
> > export_graphviz(clf, out_file=dot_data,feature_names=FEATURES)
> > with FEATURES being the array of my n2 features names in the same order
> as in X
> > I obtain the tree .png but can’t find a way to have the correct class
> names in the leaves…
> > In export_graphviz() should I use the class_names optional parameter and
> how ?
> > Thanks for any help
> >
> > Gregory, Toulouse FRANCE
> >
> >
> >
> > _______________________________________________
> > scikit-learn mailing list
> > scikit-learn at python.org
> > https://mail.python.org/mailman/listinfo/scikit-learn
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161025/5c781c8b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Extra Decision tree.png
Type: image/png
Size: 145232 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161025/5c781c8b/attachment-0001.png>
More information about the scikit-learn
mailing list