Skip to content
Advertisement

Perform incremental learning of XGBClassifier

After referring to this link I was able to successfully implement incremental learning using XGBoost. I want to build a classifier and need to check the predict probabilities i.e. predict_proba() method. This is not possible if I use XGBoost. While implementing XGBClassifier.fit() instead of XGBoost.train() I am not able to perform incremental learning. The xgb_model parameter of the XGBClassifier.fit() takes the XGBoost while I want to provide an XGBClassifier.

Is it possible to perform incremental learning of XGBClassifier since I need to make use of predict_proba() method?

Working Code:

JavaScript

Above code runs perfectly but does not has an option of retrained_model.predict_proba()

Non-working Code:

JavaScript

Above code does not work since it expects an XGBoost model or Booster instance XGBoost model to be loaded.

Error Trace:

JavaScript

Advertisement

Answer

From the docs:

xgb_model – file name of stored XGBoost model or ‘Booster’ instance[.] XGBoost model to be loaded before training (allows training continuation).

So you should be able to use xgb_model.get_booster() to retrieve the underlying Booster instance and pass that.


Also, you can get predicted probabilities out of the native xgboost API; Booster.predict returns probabilities when objective='binary:logistic'.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement