I'm working on a problem where my target feature of type integer. i.e (n_clicks). In general, if we want to predict categorical target feature then we use classification algorithms and on the other hand for predicting a target feature of type continuous then we use regression techniques where my output will be -infinity to +infinity. But in my case if I use regression then my output will become a float value. One solution here would be convert the output float values into into integer or by use of pandas.round() to round figure the value.

Is there any alternative way to predict my output variable as an integer ?


UPDATED: As suggested to use POISSON Regression, tried below code but still the output is same. Below is code snippet:

import statsmodels.api as sm
x_train_sm = sm.add_constant(x_train)
poisson_model = sm.GLM(y_train, x_train_sm, family=sm.families.Poisson()).fit()

enter image description here enter image description here


If you are using a poisson regression model, this question might be better suited for cross-validated as it is a statistical model.

This appears to be related to the reason why you are getting floats instead of the expected integer value. Poisson regression returns the expected value, E[Y|X] which does not necessarily have to be an integer.



Poisson regression is an appropriate choice when the dependent variable is a count.

  • $\begingroup$ tried that but it is also giving the same float values $\endgroup$ – Ravi Kumar B Sep 17 '19 at 9:36
  • 1
    $\begingroup$ Please post your code $\endgroup$ – Brian Spiering Sep 17 '19 at 14:43
  • $\begingroup$ The code is added to the question. $\endgroup$ – Ravi Kumar B Sep 18 '19 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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