0
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – Oxbowerce
    Feb 10, 2022 at 17:50
  • $\begingroup$ So with predict function, I will input a matrix [x1...x5] of independent values and will get output form XGBoost? Thank you for the answer $\endgroup$
    – yagiyagi
    Feb 10, 2022 at 18:20
  • $\begingroup$ You're correct, 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. $\endgroup$
    – Oxbowerce
    Feb 10, 2022 at 18:26
  • $\begingroup$ So helpful thanks, have a good day. $\endgroup$
    – yagiyagi
    Feb 10, 2022 at 18:27

1 Answer 1

0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.