Search code examples
scikit-learnxgboostsklearn-pandas

How to add weight vector to xgboost when calling via pandas_ml


In xgboost you can add a weight matrix to the data matrix (fourth argument of xgboost.DMatrix):

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

How can I pass this weight matrix when calling xgboost bia pandas_ml

http://pandas-ml.readthedocs.io/en/latest/xgboost.html

Obviously in pandas_ml xgboost is called as a method on the ModelFrame so I assume that I have to change the ModelFrame to identify the weight column. Analogously to how the target data is set is there a way you can set another column to be the weight column?

Or some other way to add the weight column?


Solution

  • You do it exactly the same way as when you are calling xgboost directly:

    clf = df.xgboost.XGBClassifier(weight=weight)