RandomforestRegregator和图形特征重要性错误

ncgqoxb0  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(255)
def graph_feature_importances(model, feature_names,autoscale=True,headroom=0.05,width=10 ,summarized_columns=None):

    if autoscale:
        x_scale =model.feature_importances_.max()+headroom
    else:
        x_scale = 1

    feature_dict=dict(zip(feature_names,model.feature_importances_))

    if summarized_columns:
        for col_name in summarized_columns:
            sum_value = sum(x for i. x in feature_dict.items() if  col_name in i)
            keys_to_remove=[i for i  in feature_dict.keys() if col_name in i]
            for i in keys_to_remove:
                feature_dict.pop(i)
            feature_dict[col_names] = sum_value

    results = pd.Series(feature_dict)
    results.sort_values(inplace = True)
    results.plot(Kind="barh" ,figsize=(width,len(results)/4),xlim=(0,x_scale))
graph_feature_importances(model,df.columns)

这里是错误

AttributeError: 'Line2D' object has no property 'kind'

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题