如何统计随机森林节点数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import make_classification X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False) rf = RandomForestClassifier(max_depth=2, random_state=0) rf.fit(X, y) print(rf.predict([[0, 0, 0, 0]])) print(rf.get_params()) # Import tools needed for visualization from sklearn.tree import export_graphviz import pydot # Pull out one tree from the forest tree = rf.estimators_[5] # Import tools needed for visualization from sklearn.tree import export_graphviz import pydot # Pull out one tree from the forest tree = rf.estimators_[5] feature_list = [ "feature1" , "feature2" , "feature3" , "feature4" ] # Export the image to a dot file export_graphviz(tree, out_file = 'tree.dot' , feature_names = feature_list, rounded = True, precision = 1) # Use dot file to create a graph (graph, ) = pydot.graph_from_dot_file( 'tree.dot' ) # Write graph to a png file graph.write_png( 'tree.png' ) |
标签:
安全分析
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
2017-09-23 dns-sd._udp.<domain>. 域名发现 本质和MDNS同