I trained an XGBoost Regression model that tries to predict the number of conversions that a campaign provides. Independent variables are monthly dummy, location dummy, and 4 columns of campaign rules (numerical). Total of 6 columns of ind. variables. I trained the model. Now I am trying to predict a given campaign's performance using this model. My aim is to input the rules, month and location of a new campaign, and get the amount of conversions that XGBoost predicts. Do you know how can I implement this kind of prediction in Python? Thanks
1 Answer
You should be able to simply use the predict
method and give it the same for which you are trying to get a prediction and the model will output the predicted value. Simply make sure that the data you want to predict on has the same format as the data you used for training (i.e. same number of columns and scaling of values if applicable) and pass it as the X argument of the predict method. If you only want to predict on one observation you might need to add an extra dimension so you have an array of shape (1, 5)
(or however many columns you have) as the model likely expects a 2D array.
predict
method and give it the same for which you are trying to get a prediction and the model will output the predicted value. $\endgroup$X
argument of the predict method. If you only want to predict on one observation you might need to add an extra dimension so you have an array of shape(1, 5)
(or however many columns you have) as the model likely expects a 2D array. $\endgroup$