2017-09-17 4 views
0

나는 scickit-learn API를 사용하여 파이썬에서 xgboost 회귀 모델을 만들고 가중치 열을 지정하려고합니다. 여기에 최소한의 코드 예입니다sampleweight가 XGBregressor에서 인식되지 않습니다.

from xgboost import XGBRegressor 
import pandas as pd 
import numpy as np 
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD')) 
model = XGBRegressor() 
model.fit(df[['A','B']],df['D'],sample_weight=df['C']) 

내가 할 때, 나는 다음과 같은 출력 얻을 :

--------------------------------------------------------------------------- 
TypeError         Traceback (most recent call last) 
<ipython-input-12-2d43e3c01bbb> in <module>() 
     6 
     7 
----> 8 model.fit(df[['A','B']],df['D'],sample_weight=df['C']) 

TypeError: fit() got an unexpected keyword argument 'sample_weight' 
지금까지 내가 말할 수있는 구문이 문서에 따르면, 올

: https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn

다른 사람은 몇 시간 전 XGBoost 개발자들에게이 문제를보고하고, 고정 된 것으로 나타납니다, 그래서이 여전히 일어나고있는 이유를 잘 모르겠어요 :

https://github.com/dmlc/xgboost/pull/1874

이 문제를 해결하는 xgboost 버전을 어떻게 설치할 수 있습니까? 나는 Ubuntu 64-bit에서 Jupyter Notebook과 Anaconda와 함께 일하고 있습니다. 아나콘다없이이 작업을 수행해야합니까?

답변

0

github에서 xgboost를 설치하여 pip에서 설치하지 않고이 문제를 해결할 수있었습니다. 나는 아직 그것을 Anaconda와 함께 작동시키지 못했지만, 다음은 나를 위해 트릭을했습니다 :

sudo apt-get install python3.6 
sudo apt-get install git 
git clone –recursive https://github.com/dmlc/xgboost 
cd xgboost; make -j4 
cd python-package; python3 setup.py install