ML and its types
What is Machine Learning?
Machine Learning (ML) is a branch of Artificial Intelligence (AI) that enables computers to learn patterns from data and make predictions or decisions without being explicitly programmed for every rule.
To understand this lets understand the difference between the Traditional Programming we know and how Machine Learning is different from that.
Traditional Programming example of Pass/Fail data.
| Student | Marks |
|---|---|
| A | 75 |
| B | 30 |
| C | 55 |
The above is the input data.
now,
Program/Rule:
IF Marks ≥ 40 → Pass
ELSE → Fail
So, the output data which comes is:
| Student | Marks | Result |
|---|---|---|
| A | 75 | Pass |
| B | 30 | Fail |
| C | 55 | Pass |
\[Data + Program → Result\]
Now how Machine Learning is different
Machine Learning example of House Price Prediction
| Area (sq.ft.) | Price (Lakhs) |
|---|---|
| 1000 | 20 |
| 1200 | 24 |
| 1500 | 30 |
| 1800 | 36 |
We, gave input in the form of Area, and output in the form of Price.
Now we will tell the computer to learn the pattern between the Input and Output,
so what the computer will is that,
\[Price ≈ 0.02 × Area\]
This learned relationship becomes the Model.
and now when we give the give the input
| Area | Predicted Price |
|---|---|
| 1600 | ? |
It will use the Model and give the output value.
| Area | Predicted Price |
|---|---|
| 1600 | 32 Lakhs |
\[Data + Result → Model\]

Machine Learning is the process of teaching a computer using examples instead of manually writing all the rules.
Think about how humans learn.
A child learns to identify a cat after seeing many examples of cats. Nobody provides a mathematical rule such as:
IF ears are triangular
AND whiskers exist
AND tail length > 20 cm
THEN Cat
Instead, the child learns from experience, Machine Learning works in a similar way.
Types of Machine Learning
Machine Learning can be divided into three major types based on how the model learns from data.
These types are:


Types of Machine Learning
1. Supervised Learning
Supervised Learning is a type of Machine Learning where the model learns using labeled data.
Labeled data means:
- Input data is available.
- Correct output is also available.
The model learns the relationship between input and output.
Supervised Learning uses labeled data to learn patterns and is mainly divided into Regression (predicting numbers) and Classification (predicting categories).
Example: Student Marks Prediction
| Study Hours | Marks |
|---|---|
| 2 | 35 |
| 4 | 55 |
| 6 | 70 |
| 8 | 90 |
The model learns the relationship between Study Hours and Marks:
It learns that when Study Hours are 2, then Marks are 35, when Study Hours are 4, then Marks are 55 and so on...
And now when it is asked that what if the Study Hours are 5, then what are the Marks?
The model predicts:
Marks ≈ 62
Working:
Working of Supervised Machine Learning
Types of Supervised Learning
Supervised Learning is mainly divided into two categories:
- Regression
- Classification
A) Regression
What is Regression?
- Regression is used to predict continuous numerical values.
- The output is a number rather than a category.
- It learns the relationship between input variables and a numerical target variable.
- Commonly used for forecasting and estimation problems.
Examples of Regression
- House Price Prediction where you have to Predict the price of a house based on features such as area, location, and number of rooms.
- Temperature Prediction where you have to Predict future temperatures using historical weather data.
- Sales Prediction where you have to Forecast future sales based on past sales records.
- Salary Prediction where you have to Estimate employee salaries based on experience, education, and skills.
Common Regression Algorithms
- Linear Regression which Predicts values using a straight-line relationship between variables.
- Polynomial Regression which creates Models non-linear relationships using polynomial equations.
B) Classification
What is Classification?
- Classification is used to predict categories or classes.
- The output belongs to a predefined group or label.
- It assigns data into one or more classes.
- Commonly used for decision-making and recognition tasks.
Examples of Classification
- Spam Email Detection which will Classify emails as Spam or Not Spam.
- Disease Prediction which will Predict whether a patient is Positive or Negative for a disease.
- Face Recognition which will Identify a person from multiple known individuals.
- Customer Churn Prediction which will Classify customers as Likely to Leave or Likely to Stay.
Common Classification Algorithms
- Logistic Regression which Predicts the probability of class membership.
- Decision Tree which Makes decisions using a tree-like structure.
- Random Forest which uses multiple decision trees to improve prediction accuracy.
- Support Vector Machine (SVM) which Separates classes using optimal decision boundaries.
Advantages of Supervised Learning
- High Accuracy as it produces accurate results when trained on quality data.
- Easy to Evaluate as its performance can be measured using evaluation metrics.
- Learns from Examples as it uses labeled data to learn patterns and relationships.
- Good for Prediction Tasks as it performs well for both regression and classification problems.
- Well-Established Algorithms as it provides many proven algorithms for different applications.
Disadvantages of Supervised Learning
- Needs Labeled Data as it Requires input data with correct output labels.
- Labeling is Expensive as creating labeled datasets can be time-consuming and costly.
- Requires Large Datasets as it often needs a significant amount of data for good performance.
- Training May Take Time as Complex models can require substantial training time.
- Limited to Known Patterns as it cannot easily identify patterns not present in the training data.
Difference between Regression and Classification
| Regression | Classification |
|---|---|
| Predicts numerical values | Predicts categories or classes |
| Output is a number | Output is a label |
| Example: House Price Prediction | Example: Spam Detection |
| Example: Sales Forecasting | Example: Disease Prediction |
| Example: Salary Prediction | Example: Face Recognition |
2. Unsupervised Learning
Unsupervised Learning is a type of Machine Learning where the model learns from unlabeled data.
Unlabeled data means:
- Input data exists.
- Correct output does not exist.
The model finds hidden patterns automatically.
Unsupervised Learning uses unlabeled data to automatically discover hidden patterns, relationships, and structures without requiring predefined output labels.
Working

Working of Unsupervised Machine Learning
Example: Customer Shopping Data
| Customer | Age | Amount Spent |
|---|---|---|
| A | 22 | 500 |
| B | 23 | 550 |
| C | 50 | 4000 |
| D | 55 | 4500 |
The model may create:
- Group 1 → Young customers, lower spending
- Group 2 → Older customer, high-spending customers
Types of Unsupervised Learning
A) Clustering
Clustering is an unsupervised machine learning technique used to group similar data points together. The objective is to identify natural patterns or structures within the data without using predefined labels.
- Data points within the same cluster share similar characteristics.
- Data points belonging to different clusters are significantly different from one another.
- Clustering helps in discovering hidden patterns and organizing large datasets into meaningful groups.
Examples
- Customer Segmentation: Grouping customers based on purchasing behavior, demographics, or preferences.
- Market Analysis: Identifying distinct market segments for targeted marketing strategies.
- Image Grouping: Organizing similar images based on visual features.
- Student Grouping: Grouping students according to academic performance, interests, or learning patterns.
- Document Categorization: Organizing documents with similar topics or content into categories.
Common Clustering Algorithms
- K-Means which divides data into K predefined clusters.
- Hierarchical Clustering which creates clusters in a tree-like hierarchy.
- DBSCAN which Groups data based on density and identifies outliers.
B) Dimensionality Reduction
Dimensionality Reduction is an unsupervised machine learning technique used to reduce the number of features in a dataset while preserving important information.
- Reduces the number of variables or features.
- Removes redundant and less useful information.
- Simplifies data analysis and visualization.
- Improves model efficiency and performance.
Applications of Dimensionality Reduction
- Data Compression: Reducing the size of data while preserving important information.
- Data Visualization: Visualizing high-dimensional data in 2D or 3D for easier interpretation.
- Noise Reduction: Removing irrelevant or noisy features from the dataset.
- Feature Reduction: Reducing the number of features to simplify model training and improve performance.
Common Algorithms
- Principal Component Analysis (PCA) which reduces dimensions while preserving maximum information.
- t-SNE which visualizes high-dimensional data in lower dimensions.
B) Association
Association is an unsupervised machine learning technique used to discover relationships between items in a dataset.
- Identifies items that frequently occur together.
- Discovers hidden patterns and associations among data items.
- Commonly used in recommendation systems and market analysis.
Examples
- Customers who buy bread often buy butter.
- Customers who buy a mobile phone may also buy a phone case.
Applications of Association
- Market Basket Analysis: Identifying products that are frequently purchased together.
- Product Recommendation: Suggesting related products based on customer purchase patterns.
- Cross-Selling Strategies: Recommending complementary products to increase sales.
- E-Commerce Analytics: Analyzing customer buying behavior to improve business decisions.
Common Association Algorithms
- Apriori Finds frequent item combinations in a dataset. It generates association rules based on item occurrence patterns.
- FP-Growth (Frequent Pattern Growth) Efficiently discovers frequent patterns in large datasets. It is faster than Apriori for large-scale data analysis.
Advantages of Unsupervised Learning
- No Labeled Data Needed as it works without predefined output labels.
- Finds Hidden Patterns and discovers relationships which is not immediately visible.
- Useful for Data Exploration which helps to understand large and complex datasets.
- Supports Feature Discovery which identifies useful structures and patterns for further analysis.
Disadvantages of Unsupervised Learning
- Hard to Evaluate as No correct answers exist for direct comparison.
- Results May Be Unclear as the Generated groups or patterns may not always be meaningful.
- Complex Interpretation for understanding discovered patterns may require domain expertise.
Difference
| Clustering | Association | Dimensionality Reduction |
|---|---|---|
| Groups similar data | Finds relationships between items | Reduces the number of features |
| Creates clusters | Creates association rules | Simplifies datasets |
| Example: Customer Segmentation | Example: Bread → Butter | Example: PCA |
| Example: Student Grouping | Example: Product Recommendation | Example: Data Compression |
3. Reinforcement Learning
Reinforcement Learning is a type of Machine Learning where an agent learns by interacting with the environment.
The agent receives Rewards for correct actions and Penalties for wrong actions. The model learns using trial and error. The goal is to maximize rewards over time.
Reinforcement Learning is a type of Machine Learning in which an agent learns through trial and error by interacting with an environment and receiving rewards or penalties for its actions.

Working of Reinforcement Machine Learning
How Reinforcement Learning Works
Step 1: Observe the Environment
The agent observes the current situation.
Step 2: Take an Action
The agent performs an action.
Step 3: Receive Feedback
The environment provides a reward or penalty.
Step 4: Learn from Experience
The agent updates its behavior based on the feedback.
Step 5: Repeat the Process
The cycle continues until the agent learns the best actions.
Simple Example: Dog Training
Sit correctly → Reward (Treat)
Wrong behavior → No reward
Repeat multiple times
The dog gradually learns the correct behavior.
Example: Self-Driving Car
Correct Action
- Stay in lane → +10 Reward
- Follow traffic rules → +10 Reward
Wrong Action
- Hit an obstacle → -20 Penalty
- Drive off the road → -20 Penalty
Result
- The car learns safe and efficient driving behavior.
Components of Reinforcement Learning
| Component | Meaning |
|---|---|
| Agent | Learner or decision maker |
| Environment | Surroundings in which the agent operates |
| Action | Task performed by the agent |
| Reward | Feedback received after an action |
| State | Current situation of the environment |
Understanding the Components of Reinforcement Learning
Agent
The Agent is the learner that makes decisions and performs actions.
- Takes actions.
- Learns from rewards and penalties.
Environment
The Environment is the world in which the agent operates.
- Receives the agent's actions.
- Provides rewards or penalties.
Action
An Action is any operation performed by the agent.
- Influences the environment.
- Examples: Move left, move right, accelerate, brake.
Reward / Penalty
A Reward or Penalty is feedback received from the environment.
- Rewards encourage correct actions.
- Penalties discourage incorrect actions.
State
A State represents the current condition of the environment.
- Describes the current situation.
- Helps the agent choose the next action.
Applications of Reinforcement Learning
Self-Driving Cars
- Learn safe driving strategies.
- Improve decision-making in different road conditions.
Robotics
- Learn movement and task execution.
- Adapt to changing environments.
Game Playing
- Learn strategies through trial and error.
- Improve performance to maximize rewards.
Recommendation Systems
- Improve recommendations based on user interactions.
- Personalize content for individual users.
Resource Management
- Optimize scheduling and resource allocation.
- Improve efficiency and reduce operational costs.
Common Reinforcement Learning Algorithms
Q-Learning
- Learns the value of actions in different situations.
- Helps the agent choose the best action to maximize rewards.
Deep Q Networks (DQN)
- Combines neural networks with Q-Learning.
- Handles complex and high-dimensional environments.
SARSA
- Learns from the current state, current action, and next action.
- Updates decisions based on actual experiences.
Policy Gradient Methods
- Learn the optimal policy directly.
- Useful for solving complex decision-making problems.
Advantages of Reinforcement Learning
Learns Automatically
- Learns through interaction with the environment.
- Does not require explicit supervision.
Improves with Experience
- Performance improves over time.
- Learns from rewards and penalties.
Useful for Dynamic Systems
- Adapts to changing environments.
- Adjusts decisions based on new situations.
Handles Complex Environments
- Solves challenging real-world problems.
- Works well when rules are difficult to define.
Learns Sequential Decisions
- Optimizes a sequence of actions over time.
- Focuses on achieving long-term rewards.
Disadvantages of Reinforcement Learning
Training Takes Time
- Requires extensive learning and experimentation.
- May take a long time to converge.
Computationally Expensive
- Needs significant computing resources.
- Often requires powerful hardware.
Requires Many Iterations
- Needs thousands or millions of interactions.
- Large amounts of training data may be required.
Complex Implementation
- Designing rewards and environments can be difficult.
- Performance depends heavily on proper setup.
Risk of Poor Learning
- Incorrect reward design can produce undesired behavior.
- The agent may learn suboptimal strategies.
Real-World Examples of Reinforcement Learning
- Self-Driving Vehicles: Learn safe and efficient driving strategies.
- Chess and Go AI Systems: Learn winning strategies through repeated gameplay.
- Warehouse Robots: Optimize navigation and task execution.
- Drone Navigation Systems: Learn efficient flight paths and obstacle avoidance.
- Traffic Signal Optimization: Improve traffic flow by adjusting signal timings.
- Autonomous Delivery Robots: Learn optimal routes for delivering packages.