2017-01-10 5 views
3

私はそのscikit学習スタイルのPythonインタフェースを経由してxgboost呼んでいる:xgboostにはfeature_importances_がありますか?

model = xgboost.XGBRegressor() 
%time model.fit(trainX, trainY) 
testY = model.predict(testX) 

一部sklearnモデルは、彼らが属性feature_importancesを経由しての機能に割り当てた重要性を教えてくれ。これはXGBRegressorのために存在していないようです:

model.feature_importances_ 
AttributeError Traceback (most recent call last) 
<ipython-input-36-fbaa36f9f167> in <module>() 
----> 1 model.feature_importances_ 

AttributeError: 'XGBRegressor' object has no attribute 'feature_importances_' 

奇妙なことがある:私の協力者のために属性feature_importances_があります!何が問題なの?

In [2]: xgboost.__version__ 
Out[2]: '0.6' 

In [4]: sklearn.__version__ 
Out[4]: '0.18.1' 

...とgithubのからxgboost C++ライブラリ、ef8d92fc52c674c44b824949388e72175f72e4d1をコミット:

これらは私が持っているバージョンです。

答えて

2

xgboostはどのようにインストールしましたか? docに記述されているようにgithubからパッケージをクローンした後にパッケージをビルドしましたか?この答えのように

http://xgboost.readthedocs.io/en/latest/build.html

Feature Importance with XGBClassifier

常にPIP-インストールとxgboostに問題があるようです。あなたのビルドからそれをビルドしてインストールすると助けになるようです。

+1

これは問題でした。ありがとうございます。ピップ経由で配布されたパッケージは古くなったようです。 – clstaudt

関連する問題