13 lines
456 B
Python
13 lines
456 B
Python
# Visualisierung eines einzelnen Entscheidungsbaums aus dem Random Forest
|
|
plt.figure(figsize=(25, 12))
|
|
tree_to_plot = rf_model.estimators_[0] # Ersten Baum aus dem Forest auswählen
|
|
plot_tree(tree_to_plot,
|
|
feature_names=X_train.columns,
|
|
class_names=['<=50K', '>50K'],
|
|
filled=True,
|
|
rounded=True,
|
|
fontsize=10,
|
|
max_depth=3)
|
|
plt.savefig('output/Random_Forest_Tree_Example.png', dpi=300)
|
|
plt.show()
|