Supervised Learning is a branch of Machine Learning where a model learns from labeled data.
Labeled data means that for every input, the correct output is already known.
Example:
The goal of supervised learning is to learn a mapping function that maps inputs to correct outputs, so the model can predict outputs for new, unseen data.
Supervised learning problems are mainly divided into:
Regression algorithms are used when the target variable is continuous, meaning it can take any numerical value.
Examples:
Linear Regression is the simplest and most fundamental regression algorithm.
It models the relationship between:
using a straight line.
The relationship is expressed as:
y = mx + c
Where:
y = predicted outputx = input featurem = slope (weight)c = intercept (bias)Predicting salary based on years of experience:
As experience increases, salary generally increases in a linear manner.
Multiple Linear Regression extends linear regression to multiple input variables.
Instead of one feature, we use many features to predict the target.
y = b₀ + b₁x₁ + b₂x₂ + ... + bₙxₙ
House price prediction based on:
Each feature contributes some weight to the final price.
Most real-world problems depend on multiple factors, not just one.
Polynomial Regression is used when the relationship between variables is non-linear, but still modeled using linear regression techniques.
Predicting car speed vs fuel consumption:
This curved relationship cannot be captured by straight lines.
These are regularized regression techniques used to solve overfitting.
When a model:
Used when:
Many features contribute small effects.
Used when:
Feature selection is required.
Classification algorithms are used when the target variable is categorical.
Examples:
Despite its name, Logistic Regression is a classification algorithm, not regression.
It predicts probabilities, which are then converted into class labels.
Sigmoid(x) = 1 / (1 + e⁻ˣ)
Predicting whether a customer will buy a product:
KNN is a distance-based algorithm.
It classifies a data point based on the majority class of its nearest neighbors.