XGboost python - classifier class weight option?

Fiction picture Fiction · Feb 12, 2017 · Viewed 14.6k times · Source

Is there a way to set different class weights for xgboost classifier? For example in sklearn RandomForestClassifier this is done by the "class_weight" parameter.

Answer

epattaro picture epattaro · Feb 28, 2017

when using the sklearn wrapper, there is a parameter for weight.

example:

import xgboost as xgb
exgb_classifier = xgboost.XGBClassifier()
exgb_classifier.fit(X, y, sample_weight=sample_weights_data)

where the parameter shld be array like, length N, equal to the target length