import lightgbm as lgb
import pandas as pd
if lgb.compat.MATPLOTLIB_INSTALLED:import matplotlib.pyplot as plt
else:raise ImportError('You need to install matplotlib for plot_example.py.')
print('Plotting split value histogram...')
ax = lgb.plot_split_value_histogram(gbm, feature='f26', bins='auto')
plt.show()
7. 绘制指定树
print('Plotting 54th tree...')# one tree use categorical feature to split
ax = lgb.plot_tree(gbm, tree_index=53, figsize=(15,15), show_info=['split_gain'])
plt.show()
8. 使用Graphviz绘制指定树
print('Plotting 54th tree with graphviz...')
graph = lgb.create_tree_digraph(gbm, tree_index=53, name='Tree54')
graph.render(view=True)
文章目录1. 加载模块2. 加载数据3. 为进一步绘图训练和记录验证结果4. 训练过程中绘制指标结果5. 绘制参数重要性6. 绘制分割值直方图(split value histogram)7. 绘制指定树8. 使用Graphviz绘制指定树1. 加载模块import lightgbm as lgbimport pandas as pdif lgb.compat.MATPLOTLIB_INSTALLED: import matplotlib.pyplot as pltelse: r