from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(n_estimators=2, max_depth=2, random_state=1) rf.fit(x_train, y_train) # 随机森林画图 i=0 for per_rf in rf.estimators_: dot_data = tree.export_graphviz(per_rf, out_file=None, feature_names=x_train.columns, class_names=['0','1'], filled=True, rounded=True, special_characters=True) graph = pydotplus.graph_from_dot_data(dot_data) i = i+1 graph.write_pdf(str(i)+"DTtree.pdf")
标签:深林,graph,graphviz,rf,train,可视化,data,True From: https://www.cnblogs.com/pass-ion/p/16917366.html