保存lightgbm模型后,如何读取重要性

2023-03-07  本文已影响0人  Colleen_oh
import lightgbm as lgb
import joblib
import matplotlib.pyplot as plt

def find_feature(path):
    model = joblib.load(path)
    # fig = plt.figure(figsize=(200, 200))
    # ax = fig.subplots()
    # print('导出决策树的pdf图像到本地')#这里需要安装graphviz应用程序和python安装包
    # graph = lgb.create_tree_digraph(model, tree_index=0, name='Tree0')
    # graph.render(view=True)

    plt.figure(figsize=(12,6))
    lgb.plot_importance(model, max_num_features=30)
    plt.title("Featurertances")
    plt.show()

find_feature(path)
image.png
上一篇 下一篇

猜你喜欢

热点阅读