Machine Learning:
Machine Learning (ML) is a branch of Artificial Intelligence (AI) that focuses on building systems that can learn from data and improve their performance over time without being explicitly programmed.
Instead of following fixed rules, machine learning algorithms use patterns and statistical models to make predictions, classifications, or decisions. If you give a machine thousands of photos labeled "cat" and "dog," it can learn the features that distinguish them. Later, when shown a new picture, it can predict whether it’s a cat or a dog.
Types of Machine Learning
Machine Learning algorithms are typically categorized into three main types, each designed to solve different kinds of problems: Supervised, Unsupervised, and Reinforcement Learning.
1. Supervised Machine Learning
Supervised learning is the most common type of machine learning.
The term "supervised" comes from the fact that the algorithm learns from a labeled dataset, which acts as a supervisor to guide the learning process.
The model is trained on data that includes both:
-
Input features (independent variables)
-
Output feature (dependent variable / label)
The goal is to learn the mapping from input → output so it can make predictions on new, unseen data.
The Labeled Dataset
A supervised dataset is divided into two parts:
-
Independent Features (Inputs): Used to make predictions (e.g., house size, number of rooms).
-
Dependent Feature (Output): The target we want to predict (e.g., house price).
Example – House Price Prediction
| Size (sq. ft.) | No. of Rooms | Price ($K) |
|---|---|---|
| 5000 | 5 | 450 |
| 6000 | 6 | 500 |
| ... | ... | ... |
Here, Size and No. of Rooms are inputs, and Price is the output.
The model learns how inputs affect the output.
Types of Supervised Learning Problems
-
Regression
-
What it is: Predicts a continuous numerical value.
-
Example: Predicting house prices ($450K, $452.5K, etc.).
-
-
Classification
-
What it is: Predicts a category or discrete label.
-
Example: Predicting whether a student will Pass or Fail.
-
Types of Classification:
-
Binary Classification: Two outcomes (Yes/No, Pass/Fail, Spam/Not Spam).
-
Multi-class Classification: More than two outcomes (e.g., Spam, Promotional, Social emails).
-
-
2. Unsupervised Machine Learning
Unlike supervised learning, unsupervised learning works with unlabeled data.
Here, the algorithm is given only inputs and must find hidden patterns or structures without guidance.
Discover hidden groupings or structures in the data. Example – Customer Segmentation
Imagine you run an e-commerce company with a dataset of customer salaries and spending scores.
You want to segment customers for a targeted marketing campaign.
| Salary ($K) | Spending Score (1–10) |
|---|---|
| 20 | 9 |
| 45 | 2 |
| ... | ... |
Using clustering (a type of unsupervised learning), the algorithm might group customers like:
-
Cluster 1: High Salary, High Spender → Premium customers
-
Cluster 2: Low Salary, Low Spender → Budget customers
-
Cluster 3: High Salary, Low Spender → Price-conscious professionals
3. Reinforcement Learning
Reinforcement learning is a different paradigm.
Here, an agent learns to make decisions by interacting with an environment, receiving rewards or penalties for its actions. Learn through trial and error to maximize rewards and minimize penalties is the main idea.
Example – A Baby Learning to Walk
-
Agent: The baby
-
Environment: The room
-
Actions: Standing up, taking steps, falling
-
Goal: Walk across the room
-
Rewards: Successful steps without falling
-
Penalties: Falling, which teaches adjustments
The baby gradually learns a strategy to walk efficiently.
Similarly, reinforcement learning models improve over time by maximizing long-term rewards.
Real-World Applications
-
Self-driving cars
-
Robotics
-
Game-playing AI (e.g., AlphaGo beating world champions)
The Geometry of Machine Learning: Lines, Planes, and Hyperplanes
Before diving into algorithms like Logistic Regression and Support Vector Machines (SVM), it’s important to understand the geometric concepts :
-
The equation of a line (2D)
-
The equation of a plane (3D)
-
The equation of a hyperplane (N-Dimensions)
1. The Equation of a Straight Line (2D)
In 2D (X and Y axes), a straight line is represented by the classic equation:
-
x, y → Coordinates on the plane
-
m → Slope of the line (rise/run). Positive slope = upward line, negative slope = downward line.
-
c → Y-intercept (point where the line crosses the y-axis when ).
Generalized Notation for Machine Learning
In ML, we often write the line equation in a more general form:
-
→ Input features (instead of x and y)
-
→ Weights/coefficients (control slope & feature importance)
-
→ Bias or intercept
Using vector notation:
This form is compact and easily extends to higher dimensions.
2. The 3D Plane
When we add a third variable (), the line equation extends to define a plane in 3D space.
-
Equation:
-
Vector notation:
3. The Hyperplane (N-Dimensions)
In machine learning, we often work with high-dimensional data (dozens, hundreds, or thousands of features).
In such cases, the plane generalizes into a hyperplane.
-
Definition:
A hyperplane is an -dimensional flat subspace in an -dimensional space.-
A line is a 1D hyperplane in 2D.
-
A plane is a 2D hyperplane in 3D.
-
-
Equation (n dimensions):
-
Vector form:
4. Special Case: Passing Through the Origin
If a line, plane, or hyperplane passes through the origin (all coordinates = 0), the intercept term vanishes:
This tells us something fundamental: the vector is perpendicular (orthogonal) to the hyperplane.
5. The Significance of the Vector
The vector plays a key geometric role:
-
In 2D (line): is perpendicular to the line.
-
In 3D (plane): is perpendicular to the plane.
-
In n-D (hyperplane): is perpendicular to the hyperplane.
This orthogonality is crucial in ML algorithms like SVM and Logistic Regression, where the hyperplane becomes the decision boundary that separates different classes of data points.
Instance-Based vs. Model-Based Learning: A Key Distinction
When a machine learning model learns from data, it does so in one of two ways:
-
Memorizing the training data
-
Generalizing from it
This distinction forms the basis of two different learning paradigms: Instance-Based Learning and Model-Based Learning.
Understanding this difference is crucial when choosing the right algorithm for a problem.
The Core Analogy
-
Instance-Based Learning → Like memorizing notes before an exam. Predictions are made by directly comparing new data to past examples.
-
Model-Based Learning → Like understanding the concepts. The system finds general rules and applies them to future problems without referencing past data.
1. Instance-Based Learning (Memorizing)
In this approach, the model does not build a general rule. Instead, it stores all training data and uses it directly for predictions. “To predict a new data point, find its closest neighbors in the training data and use their outcomes.”
Example – Student Pass/Fail Classification
-
Dataset: Hundreds of students labeled Pass or Fail
-
New student’s data comes in
-
An Instance-Based Model (like K-Nearest Neighbors – KNN):
-
Finds the 5 closest students (neighbors) in the dataset
-
If 4 out of 5 passed → Predicts the new student will pass
-
No formula, no boundary. The prediction is made on the fly using stored data.
2. Model-Based Learning (Generalizing)
Here, the model analyzes training data to discover patterns and creates a generalized model (rule or decision boundary).The main idea is “I will learn a general rule from the data and use it for all future predictions.”
Example – Student Pass/Fail Classification
-
Dataset: Same student dataset (study hours, play hours → Pass/Fail)
-
A Model-Based Algorithm (like Logistic Regression):
-
Finds a mathematical relationship between inputs and outcome
-
Creates a decision boundary separating Pass vs. Fail students
-
For a new student → Just checks which side of the boundary they fall on
The model generalizes knowledge into a compact rule instead of memorizing all data. -
Side-by-Side Comparison
| Feature | Model-Based Learning | Instance-Based Learning |
|---|---|---|
| Learning Process | Learns patterns → creates a generalized model | Memorizes training data directly |
| Pattern Discovery | Done during training | Done only when a prediction is requested |
| Model Storage | Stores a small model file (rules, weights, boundary) | Must keep the entire dataset |
| Speed (Prediction) | Very fast (just apply model) | Slower (search through dataset each time) |
| Data Requirement | Can discard original data after training | Needs original dataset always |
| Common Algorithms | Linear/Logistic Regression, Decision Trees, SVM | K-Nearest Neighbors (KNN) |
Test Your Understanding
Take this interactive quiz to reinforce what you've learned. Earn badges, track your streak, and master the concepts!
- 5-10 questions per quiz
- Earn achievement badges
- Build answer streaks
- Track your speed