I have trained an XGBoost classification model for sentiment analysis of product reviews. However, there are certain cases where the model predictions are not as expected. For example, when I input the review "The delivery was a bit late but the product was awesome", the model classifies it as a negative review (0), but I want to fine-tune the model on that exact case to say the review is positive (1).
Is there a way to fine-tune the already trained XGBoost model by adding specific data points like this? What would be the best approach to achieve this without retraining the whole model from scratch?
I've tried the following function:
# Fine tune the model
def fine_tune(model, inp, output, word2vec):
model.fit(
np.array([word2vec.get_mean_vector(tokenize(
inp
))]), np.array([output])
)
return model
However, when I run it it retrains the whole model on that single data point I provide it with.
Any guidance or suggestions would be greatly appreciated. Thank you!
Thanks to @Laassairi Abdellah he was able to redirect me incremental training. Armed with that knowledge I've made this function:
The loop section of this code is specific to my use case of binary classification as in it is either 1 or 0.
Example usage: