I just started machine learning , and I was confused about which model to use, regression or classification , when we have a target variable like age or a variable like movie rating , which may have any value between 1 and 10.

In general , I am not able to decide whether to consider these variables as categorical or continuous, even when they are present as features.


1 Answer 1


Use classification when the number of categories are limited and nothing in between makes sense. For example a class is either a dog or a cat nothing in between.
But when it comes to something like ratings, 3 is as likely acceptable as 3.5 ((so is 3.56, etc) so you are not bound to only one value among others. it can be in between as well.

Apart from this, age is kind of interesting as some people may see it as a closed number of classes(classification), while others treat it as a regression problem, as the individual can have any age and its not fixed to an upper bound in theory. A person is likely to be 1 years old, or 120 years old! it could be something in between as well.
Then again some may say that, we know people normally don't live past a certain age, like 120! so we create 120 classes, and people can be in any of such categories and it makes sense and is enough!
Just note that this may not apply to all situations (and it does/will not), when you for example are going to lets say, get the age of some substances, this may not hold as easily. also it does not apply when you have unbounded ranges.
so age is inherently a regression problem, that based on the situation may be represented as a classification problem by some.

  • $\begingroup$ Great explanation ! But in case of movie rating , the target variable is bounded between 0 and 10 . If I model this as a regression problem , how would I impose the bounds on my prediction. Isn't it possible that the model can predict (although less likely) out of bounds ? $\endgroup$ Oct 27, 2020 at 2:40
  • 1
    $\begingroup$ if you have enough training data, the network will get to the range thats specified in your training set and you'll be fine. During testing, in case, it goes outof its way and predicts a number ouf of range! you can put a hard limit on the output. e.g. if the model rates something as 11, you can set it to 10 and vice versa, if it predicted a value like -1, set it to 0. basically this is a presentation layer logic. other than this, if you feel like, an integer rating system is fine, then classification would be good since only integers are allowed, but if you want sth like 5.6, go regression $\endgroup$
    – Hossein
    Oct 27, 2020 at 3:33

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.