Supervised Machine Learning is a core branch of machine learning where algorithms learn to map inputs (X) to known outputs or labels (Y). The key idea is to train the model using labeled data—examples that include both the input and the correct output—so it learns the relationship between the two.
By repeatedly analyzing these input-output pairs, the algorithm gradually learns to generalize. Once trained, it can accurately predict outputs for new, unseen inputs. For instance, in a speech recognition system, the model might be trained on audio recordings (inputs) and their corresponding transcripts (outputs). After learning from many examples, it can transcribe new audio clips on its own.
Supervised learning tasks generally fall into two main categories: regression and classification.
Regression
Regression algorithms are used when the output is a continuous numerical value. These models aim to predict a quantity from an infinite range of possible values.
Example:
Predicting the price of an apartment based on its size in square meters. Here, the input is the size of the flat, and the output is a continuous value: the price.
Classification
Classification algorithms, on the other hand, are used when the output is one of a limited set of predefined categories, also known as classes. These categories can be numeric (like 0 or 1) or non-numeric (such as "benign" or "malignant").
Example:
In a medical diagnosis scenario, you might want to classify a tumor as benign or malignant based on features like tumor size and patient age. This is a classic binary classification problem.
Regression vs. Classification: A Comparison
| Feature | Regression | Classification |
|---|---|---|
| Output Type | Continuous numeric values | Discrete categories or classes |
| Goal | Predict a number | Predict a class label |
| Examples of Output | Price, temperature, age | Yes/No, spam/ham, disease type |
| Number of Output Values | Infinite (within a range) | Finite (typically a small set of classes) |
| Example Use Case | Predicting house price from size and location | Determining if an email is spam or not |
| Evaluation Metrics | Mean Squared Error (MSE), Mean Absolute Error (MAE) | Accuracy, Precision, Recall, F1-Score |
| Algorithm Examples | Linear Regression, Ridge Regression, Lasso | Logistic Regression, Decision Trees, SVM, k-NN |
| Input Features Example | Square meters of a flat | Age and tumor size |
| Nature of Problem | Predicting quantities | Assigning categories |