What is the difference between classification and regression?
Classification predicts a category (spam or not spam, pass or fail). Regression predicts a continuous number (a house price, tomorrow's temperature). The choice depends on the type of the target column, not on the algorithm.
Explain it simply
Think of two questions a cricket analyst might ask. "Will India win this match: yes or no?" has a fixed set of possible answers, so it is classification. "How many runs will Kohli score?" can be 0, 37, 102 or any other number on a scale, so it is regression.
The rule is simple: look at the thing you want to predict. If it is a label from a fixed list, you need a classifier. If it is a quantity where being close still counts, you need a regressor.
Example
Predict if a student gets placed (Yes / No) -> classification
Predict the salary offered (in lakhs per year) -> regression
Predict the grade (A, B, C, D) -> classification
Predict the CGPA at the end of 4 years -> regressionMany algorithms come in both flavours: decision trees, random forests, KNN and SVM all have a classifier and a regressor version. Even logistic regression, despite its name, is a classifier: it outputs a probability, and you pick a threshold such as 0.5 to turn it into a label.
Metrics differ too. Classification uses accuracy, precision, recall and F1. Regression uses MAE, RMSE and R squared.
What to say in the interview
"The target decides it. A categorical target means classification, a continuous numeric target means regression. Some problems can be framed either way, for example predicting salary exactly versus predicting a salary band, and the business need decides which is more useful."
Common mistakes
- Treating a numeric-looking label such as 1, 2, 3 for classes as a regression target.
- Calling logistic regression a regression algorithm.