[英]Accessing feature importance in XGBoost version 0.6 (Python)
I'm trying to to get the feature importance for my xgboost model but I'm always getting this error: 我正在尝试获取我的xgboost模型的功能重要性,但我总是遇到此错误:
AttributeError: 'XGBModel' object has no attribute 'feature_importances_'
I read that this might be a versioning issue, but I installed this in late December 2016 and I believe this is the version that supposedly fixed this problem. 我读到这可能是版本控制问题,但是我在2016年12月下旬安装了该版本,我相信这是应该解决此问题的版本。
Can anyone help me get the feature importances? 谁能帮助我了解功能的重要性?
import numpy as np
import pandas as pd
import xgboost as xgb
print "XGB Version: " + str(xgb.__version__)
np.random.seed(0)
df = pd.DataFrame(np.random.randint(0,1000,size=(1000, 5)), columns=list('ABCDE'))
x = df.ix[:,0:4]
y = df.ix[:,4]
mod = xgb.XGBModel()
mod.fit (x,y)
mod.feature_importances_
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.