美文网首页
ValueError: Invalid decision typ

ValueError: Invalid decision typ

作者: 菜菜鑫 | 来源:发表于2020-07-27 11:39 被阅读0次

    使用LightGBM模型可视化时报错ValueError: Invalid decision type in tree model.

    lgb.create_tree_digraph()
    lgb.plot_tree()
    

    错误定位到python-package/lightgbm/plotting.py中的271行
    原因是root['decision_type']为'<=',而判断条件错误,微软官方LightGBM好像已经修正了错误,但可能是我安装版本的问题
    解决方法为进入/.local/lib/python3.6/site-packages/lightgbm目录
    管理员权限打开文件sudo gedit plotting.py
    相关位置修改为如下代码

                    if info in {'split_gain', 'internal_value', 'internal_count'}:
                        label += '\n' + info + ':' + str(root[info])
                graph.node(name, label=label)
                # if root['decision_type'] == 'no_greater':
                if root['decision_type'] == '<=':
                    l_dec, r_dec = '<=', '>'
                # elif root['decision_type'] == 'is':
                elif root['decision_type'] == '=':
    

    完美解决
    参考:https://github.com/microsoft/LightGBM/pull/810/files/7e824df64a739b6818f2d10bf3dbdc2cfd7fe876

    \color{red}{(原创,转载请注明来源)}

    相关文章

      网友评论

          本文标题:ValueError: Invalid decision typ

          本文链接:https://www.haomeiwen.com/subject/lmqzlktx.html