0

I'm trying to calibrate the output probabilities from a XGBClassifier.

I've provided the sample code,

x_train, x_test, y_train, y_test = train_test_split(x_var, y_var, test_size = 0.2, shuffle = False)
new_mod2 = xgb.XGBClassifier(scale_pos_weight = 1, eta = 0.3, nthread = 10, learning_rate = 0.05, max_depth = 2, n_estimators = 180, objective = 'binary:logistic' )  
calibrated = CalibratedClassifierCV( base_estimator = new_mod2,method = 'Isotonic', cv=3)
calibrated.fit(X = x_train, y = y_train)

But when running the calibrated.fit() function, I get the following error:

TypeError: predict_proba() got an unexpected keyword argument 'X'

It's my understanding that the calibratedclassifiercv should work with the sklearn xgboost wrapper.

Yet the calibrated classifier cv seems to be passing the incorrect variable to the predict_proba() method of xgboost.

Is there any reason this might be occurring?

Redratz
  • 136
  • 7
  • Please provide the whole error traceback. And it would be helpful if you can provide a minimal reproducible example: here, that would mean including a data sample that demonstrates this error (either a small simplified version of yours, or perhaps one of the sklearn builtin datasets). – Ben Reiniger Feb 23 '21 at 14:40
  • Possibly related to https://stackoverflow.com/q/65517931/10495893 – Ben Reiniger Feb 23 '21 at 22:36
  • 1
    Does this answer your question? [Xgboost not running with Callibrated Classifier](https://stackoverflow.com/questions/65517931/xgboost-not-running-with-callibrated-classifier) – Ben Reiniger Feb 25 '21 at 22:02
  • After continuing to test, I found that given enough data and setting the objective function to logloss, the xgboost achieved fairly well calibrated posterior probabilities. Atleast based on viewing the calibration plot. – Redratz Mar 12 '21 at 19:59

0 Answers0