栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

可视化决策树(来自scikit-learn的示例)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

可视化决策树(来自scikit-learn的示例)

您运行哪个操作系统?你已经

graphviz
安装好了吗?

在您的示例中,

StringIO()
对象保存
graphviz
数据,这是一种检查数据的方法:

...>>> print out.getvalue()digraph Tree {0 [label="X[2] <= 2.4500nerror = 0.666667nsamples = 150nvalue = [ 50.  50.  50.]", shape="box"] ;1 [label="error = 0.0000nsamples = 50nvalue = [ 50.   0.   0.]", shape="box"] ;0 -> 1 ;2 [label="X[3] <= 1.7500nerror = 0.5nsamples = 100nvalue = [  0.  50.  50.]", shape="box"] ;0 -> 2 ;3 [label="X[2] <= 4.9500nerror = 0.168038nsamples = 54nvalue = [  0.  49.   5.]", shape="box"] ;2 -> 3 ;4 [label="X[3] <= 1.6500nerror = 0.0407986nsamples = 48nvalue = [  0.  47.   1.]", shape="box"] ;3 -> 4 ;5 [label="error = 0.0000nsamples = 47nvalue = [  0.  47.   0.]", shape="box"] ;4 -> 5 ;6 [label="error = 0.0000nsamples = 1nvalue = [ 0.  0.  1.]", shape="box"] ;4 -> 6 ;7 [label="X[3] <= 1.5500nerror = 0.444444nsamples = 6nvalue = [ 0.  2.  4.]", shape="box"] ;3 -> 7 ;8 [label="error = 0.0000nsamples = 3nvalue = [ 0.  0.  3.]", shape="box"] ;7 -> 8 ;9 [label="X[0] <= 6.9500nerror = 0.444444nsamples = 3nvalue = [ 0.  2.  1.]", shape="box"] ;7 -> 9 ;10 [label="error = 0.0000nsamples = 2nvalue = [ 0.  2.  0.]", shape="box"] ;9 -> 10 ;11 [label="error = 0.0000nsamples = 1nvalue = [ 0.  0.  1.]", shape="box"] ;9 -> 11 ;12 [label="X[2] <= 4.8500nerror = 0.0425331nsamples = 46nvalue = [  0.   1.  45.]", shape="box"] ;2 -> 12 ;13 [label="X[0] <= 5.9500nerror = 0.444444nsamples = 3nvalue = [ 0.  1.  2.]", shape="box"] ;12 -> 13 ;14 [label="error = 0.0000nsamples = 1nvalue = [ 0.  1.  0.]", shape="box"] ;13 -> 14 ;15 [label="error = 0.0000nsamples = 2nvalue = [ 0.  0.  2.]", shape="box"] ;13 -> 15 ;16 [label="error = 0.0000nsamples = 43nvalue = [  0.   0.  43.]", shape="box"] ;12 -> 16 ;}

您可以将其编写为.dot文件并产生图像输出,如链接的源中所示:

$ dot -Tpng tree.dot -o tree.png
(PNG格式输出)



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/668988.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号