Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unit 1 - Introduction to Machine Learning
1.1 Basics of ML - Define Machine Learning, Traditional programming vs ML-based approaches,
Role and application of ML in artificial intelligence and data science
Definition of Machine Learning (ML)
Question: Define Machine Learning
Machine Learning (ML) is a branch of Artificial Intelligence (AI) that enables computer
systems to learn patterns from data and make predictions or decisions without being
explicitly programmed for specific tasks.
Arthur Samuel defined machine learning as “the field of study that gives computers the
ability to learn without being explicitly programmed”.
In simple words, ML teaches the systems to think and understand like humans by learning
from the data.
Traditional programming vs ML-based approaches
Question - With the help of diagram describe traditional programming approach
Traditional Programming
In traditional programming, rules and logic are explicitly defined by humans. Programmers
write code that specifies how inputs are processed to produce outputs.
It works well when the problem is well-understood and can be described in clear,
deterministic rules.
Example: Writing a program to calculate income tax - rules and formulas are coded step by
step.
Structure: Input + Rules (Programmer defined) → Output
We have input data, and the programmer writes the program/rules that use that data and
execute on a computer to generate the output/answer as shown in Fig.
Machine Learning (ML)-based Approaches
Question - Explain ML-based approaches with diagram.
In ML, we don’t explicitly define the rules. Instead, the system learns patterns and rules
automatically from data.
The programmer provides an algorithm and training data, and the machine figures out the
logic. This is useful for complex problems where it’s hard to define rules manually.
Example: Image recognition - instead of writing rules for every possible pixel arrangement,
ML models learn patterns from thousands of labelled images.
Structure: Input + Output (Data) → Model learns Rules.
pg. 1 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In case of machine learning, data and output/answers (or labels) come in as input and the
learning rules (models) come out as output as shown in Fig.
Difference
Question - Difference between Traditional programming vs ML-based approaches
Aspect Traditional Programming Machine Learning Approach
Approach
Approach Programmer writes explicit rules System learns rules automatically from
(like if-else logic). data.
Input Data + Human-written rules. Data + Expected outputs (labels) or
patterns.
Output Program output (results). Learned model (that can predict outputs).
Flexibility Works well when rules are clear Works well for complex, fuzzy or evolving
and fixed. problems.
Development Linear (write, debug, deploy). Iterative (train, evaluate, tune, retrain).
Process
Data Handling Structured, predictable data. Large, often unstructured data.
Instruction Explicit rules and logic. Learns patterns from data.
Method
Examples Payroll systems, calculators, Spam detection, speech recognition,
traffic lights. recommendation engines.
Role and Application of ML in Artificial Intelligence (AI) and Data Science
Question- What is the role of Machine Learning in artificial intelligence and data science?
Every second, huge amounts of data are generated every second from different sources like
social media, business transactions, healthcare, e-commerce, scientific research, and IoT
devices.. This large data is useful only when it is analyzed properly to extract meaningful
insights and support decision-making.
To solve this problem, three related fields—AI, Data Science, and Machine Learning—have
become important.
pg. 2 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Fig. ML vs AI vs Data Science
Data Science focuses on handling vast volumes of data using modern tools and techniques
to find unseen patterns, derive meaningful information, and support business decisions.
Data Science uses complex machine learning algorithms to build predictive models.
Machine Learning (ML) is a key component of Data Science that focuses on developing
algorithms and models that enable computers to learn from data.
Combining AI and Machine Learning with Data Science helps create new innovations.
Role of ML in Artificial Intelligence (AI)
1. Enabling Intelligence: - ML acts as the engine powering modern AI systems and enables
intelligent behavior.
2. Learning and Adaptation:- ML allows AI systems to learn from experience and improve
performance without explicit reprogramming.
3. Core Capabilities: - ML supports AI functions such as inference, adaptation, and
generalization.
4. Examples: - Personalized advertisements, language translation, and virtual assistants.
Role of ML in Data Science
1. Pattern Recognition: - ML identifies patterns in data that are difficult for humans to find
manually.
2. Predictive Modeling: - ML builds models that predict future outcomes using historical data.
3. Automation: - ML automates complex tasks such as fraud detection, recommendation
systems, and spam filtering.
4. Data Processing: - ML relies on data science techniques to clean, prepare, and analyze data
before learning.
pg. 3 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Applications of ML in AI and Data Science
Question- Explain different applications of Machine Learning in artificial intelligence and data
science.
Machine Learning is widely used in many fields to analyze data, make smart decisions, and
solve real-world problems.
It is applied in areas like healthcare, finance, marketing, and transportation to improve
decision-making, automate tasks, and enhance user experience.
1. Natural Language Processing (NLP)
Enables machines to understand and generate human language.
Applications: Machine translation (Google Translate), sentiment analysis, speech
recognition, chatbots.
In Data Science, NLP analyzes large volumes of unstructured text data.
2. Computer Vision
Enables machines to interpret visual information.
Examples: Facial recognition, medical imaging, autonomous driving, surveillance.
In Data Science, computer vision helps analyze satellite images and manufacturing defects.
3. Healthcare and Medicine
ML supports disease prediction, diagnosis, and drug discovery.
Used in electronic health record analysis and personalized treatment.
Examples: Cancer detection and heart disease risk prediction.
4. Finance and Business Analytics
ML enables fraud detection, algorithmic trading, and robo-advisors.
Analyzes customer transactions and predicts market trends.
Used in recommendation systems (Amazon, Netflix, Spotify).
5. Transportation and Autonomous Systems
ML powers self-driving cars and navigation systems.
Used for traffic prediction and route optimization.
6. Cybersecurity and Anomaly Detection
ML detects intrusions, malware, and unusual system behavior.
Identifies suspicious transactions and potential data breaches.
7. Scientific Research and Engineering
ML assists in robotics, climate modeling, and automated scientific discovery.
Used to analyze experimental data and optimize industrial processes.
8. Retail and Marketing
ML personalizes recommendations and customer experiences.
Supports demand forecasting, dynamic pricing, and customer segmentation.
pg. 4 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Difference
Question- Write Difference between AI, ML & DS
Point Artificial Intelligence (AI) Machine Learning (ML) Data Science (DS)
1 AI is a broad field of ML is a subset of AI. Data Science is a separate
creating intelligent but related field.
machines.
2 Focuses on making Focuses on enabling Focuses on analyzing and
machines think and act like machines to learn from data. interpreting data.
humans.
3 Can work with or without Always works with data. Always works with data.
data (rule-based systems).
4 Can use rules, logic, or Uses algorithms and models Uses ML, statistics, and data
learning methods. to learn patterns. analysis tools.
5 Output is intelligent Output is prediction or Output is insights, reports,
decision or action. classification. and visualizations.
6 Example: Robot, chatbot, Example: Spam filter, Example: Sales analysis,
self-driving car. recommendation system. customer behavior analysis.
1.2 Types of ML (Supervised, Unsupervised, Reinforcement Learning)-Supervised Learning:
Definition, working principle, examples (classification, regression), Unsupervised Learning:
Definition, working principle, examples, Clustering, dimensionality reduction techniques,
Reinforcement Learning: Concept of agents, rewards, and policy learning, Comparison of
different ML types with real world applications
Types of ML
Question- Explain different types of Machine Learning
Machine Learning (ML) can be classified into three major types:
Supervised Learning, Unsupervised Learning, and Reinforcement Learning.
These types differ based on the nature of data available and the learning strategy used to improve
performance.
pg. 5 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. Supervised Learning – Learning with Labeled Data
Supervised learning is the most commonly used type of Machine Learning.
In this approach, the algorithm is trained using a labeled dataset, where both input data
and correct output (target/ground truth) are provided.
The main goal of the algorithm is to learn the relationship (mapping) between input and
output so that it can make accurate predictions on new data.
Example:
A dataset contains the number of hours studied and the exam score of students.
By learning this relationship, the model can predict the score for a student who studies a given
number of hours.
Types of Supervised Learning
Classification: Predicts categorical output
o Example: Email is spam or not spam
Regression: Predicts continuous values
o Example: Predicting a student’s marks based on the number of hours studied.
Advantages:
High accuracy when sufficient labeled data is available
Limitation:
Requires large labeled datasets, which are costly and time-consuming to prepare
2. Unsupervised Learning – Discovering Patterns from Unlabeled Data
Unsupervised learning works with unlabeled datasets, where no correct output is provided.
The algorithm discovers patterns, structures, or groups in the data without guidance.
Example:
In customer purchase data, there are no predefined customer groups, but the algorithm can find
similar purchasing patterns.
Types of Unsupervised Learning
Clustering: Groups similar data points
o Example: Customer segmentation
Dimensionality Reduction: Reduces number of features while keeping important
information
o Example: Principal Component Analysis (PCA)
Association Rule Learning: Finds relationships between items
o Example: Customers who buy bread also buy butter
Advantage:
Useful for discovering hidden patterns
Limitation:
Difficult to evaluate results due to absence of labels
pg. 6 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3. Reinforcement Learning – Learning Through Trial and Error
Reinforcement Learning is based on learning by interaction with an environment.
An agent takes actions and receives rewards or penalties as feedback.
The objective is to learn an optimal policy that maximizes total reward over time.
Example:
A computer learning to play chess improves its strategy by receiving feedback such as winning or
losing.
Applications of Reinforcement Learning
Robotics (robot movement and control)
Game playing (chess, video games)
Autonomous systems (self-driving cars)
Challenge:
Balancing between trying new actions and using known actions that give high rewards
Supervised Learning
Question- What is supervised machine learning? Describe with example. OR Explain working
principle of supervised machine learning
Definition: Supervised learning is a type of machine learning that trains the model using
labeled datasets to predict outcomes. A Labeled dataset is one that consists of input data
(features) along with corresponding output data (targets).
The training data works as a supervisor that guides the machine to predict the correct
output.
This learning process is similar to how a student learns under the guidance of a teacher.
In supervised learning, the aim of the algorithm is to learn a mapping function that maps
the input variable (X) to the output variable (Y).
If input is denoted by X and output by Y, then supervised learning tries to learn a function
f(X) → Y, so that for a new input value, the model can correctly predict the output.
Example
Consider a dataset of fruits where each record contains color, size, and shape as input features
and the fruit name such as apple, banana, or mango as the output label.
By learning from these labeled examples, the model can correctly identify the fruit for new input
data.
Supervised learning is widely used in real-world applications such as:
Risk assessment
Image classification
Fraud detection
Spam filtering
pg. 7 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Working Principle of Supervised Learning
In supervised learning, the model is trained using a labeled dataset.
After training, the model is tested using test data and then used to predict outputs for new data.
The working of supervised learning is explained in the following steps:
1. Collect Labeled Data
Gather a dataset where each input has a known correct output (label).
Example: Images of handwritten digits with their actual numbers as labels.
2. Split the Dataset
Divide the data into training data (about 80%) and testing data (about 20%).
The model will learn from the training data and be evaluated on the testing data.
3. Train the Model
Feed the training data (inputs and their labels) to a suitable supervised learning algorithm
(like Decision Trees, SVM or Linear Regression).
The model tries to find patterns that map inputs to correct outputs.
4. Validate and Test the Model
Evaluate the model using testing data it has never seen before.
The model predicts outputs and these predictions are compared with the actual labels to
calculate accuracy or error.
5. Deploy and Predict on New Data
Once the model performs well, it can be used to predict outputs for completely new, unseen
data.
Types of Supervised Learning
Supervised learning techniques are broadly classified into two types based on the nature of
the target variable namely, Classification (predicting categorical values) and Regression
(predicting continuous values).
pg. 8 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Classification
Question - Explain classification in detail.
Classification is one of the most important types of Supervised Learning.
Definition: Classification is a type of supervised machine learning in which the model
predicts a categorical (discrete) output for a given input based on labeled training data
The model is trained using input features (X) and output labels (Y). During training, it learns
how inputs are related to different classes.
After training, the model uses this learning to predict the class of new and unseen data.
Example- Predicting whether an email is Spam or Not Spam.
Types of Classification Problems in Machine Learning
Classification problems can be categorized into different types depending on the number of
target classes, relationships between them, and whether a data point can belong to one or
multiple categories.
1. Binary Classification
Binary classification is the simplest and most common classification type.
It involves two possible outcomes (two categories/classes).
Example: Predicting whether an email is Spam or Not Spam.
2. Multi-class Classification
Multi-class classification deals with problems where there are more than two categories and
each input belongs to exactly one class.
Examples: Classifying types of news articles (Sports, Politics, Entertainment).
3. Multi-label Classification
Unlike multi-class, multi-label classification allows each input to belong to multiple classes
simultaneously.
Examples: A movie can be tagged as Action + Comedy + Drama.
4. Imbalanced Classification (Special Case)
This is not a separate category but a special scenario where one class is much more frequent
than the other(s).
Example: Fraud detection: 99.9% transactions are legitimate, only 0.1% are fraudulent.
pg. 9 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Common Classification Algorithms
1. Logistic Regression: Used for binary classification like spam or not spam.
2. Support Vector Machine (SVM): Good for classification when data has many features.
3. Decision Tree: Uses a tree structure to make class predictions.
4. Random Forest: Uses multiple decision trees to improve accuracy and reduce overfitting.
5. K-Nearest Neighbors (KNN): Classifies data based on the nearest data points.
Regression
Question- What is regression? Explain in detail
Definition- Regression in machine learning is a supervised learning technique used to predict
continuous numerical values by learning relationships between input variables (features)
and an output variable (target).
The goal of regression is to predict a numerical value based on the relationships between
input features and the output variable.
Regression is widely used in prediction, forecasting and trend analysis.
For example- Predicting a student’s marks based on the number of hours studied.
Types of Regression
There are multiple types of regression techniques, each designed to handle specific types of data,
relationships, and challenges.
1. Simple Linear Regression:
- It predicts output using one independent variable and shows a straight-line relationship.
Example: Predicting marks based on study hours.
2. Multiple Linear Regression:
- It predicts output using two or more independent variables.
Example: House price based on size, location, and number of rooms.
pg. 10 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3. Polynomial Regression:
- It is used when data shows a curved (non-linear) relationship.
Example: Population growth over time.
4. Logistic Regression
- It is Used for classification problems, predicts outcomes like Yes/No.
5. Ridge Regression
- Reduces overfitting by adding a penalty to large coefficients.
Common Regression Algorithms:
1. Linear Regression: Draws a straight line to show the relationship between input and output
values.
2. Polynomial Regression: Uses curved lines to handle non-linear data.
3. Decision Tree Regression: Predicts values using decision rules in a tree structure.
4. Random Forest Regression: Uses many decision trees to give more accurate results.
5. Support Vector Regression (SVR): Predicts values by fitting the best line within a margin.
Advantages and Disadvantages of Supervised Learning
Advantages of Supervised Learning
1. High Accuracy-Since the model is trained using labeled data, it usually gives accurate results.
2. Easy to Understand and Train - Supervised learning is easier to implement because input
and correct output are already known.
3. Predictive Power - It can predict future outcomes based on past data.
4. Clear Performance Measurement - Model performance can be easily measured using
known outputs.
5. Useful for Classification and Regression - Works well for problems like spam detection,
disease prediction, and price prediction.
Disadvantages of Supervised Learning
1. Requires Labeled Data- Preparing labeled data is time-consuming and expensive.
2. Not Suitable for Unknown Patterns- The model cannot find new patterns beyond the given
labels.
3. Needs Large Dataset- A large amount of labeled data is needed for good performance.
4. Overfitting Risk- The model may learn training data too well and perform poorly on new
data.
5. Human Effort Required - Human involvement is needed for data labeling and correction.
pg. 11 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unsupervised Learning
Question-What is unsupervised machine learning? Describe with example. OR Explain working
principle of unsupervised machine learning
Definition: Unsupervised Learning is a type of Machine Learning where the model is trained
using unlabeled data, meaning no correct output is given.
The system learns by discovering hidden patterns, structures, or relationships in the data on
its own.
In Simple words, The machine learns without answers.
There is no supervision or guidance given to the model during training.
The model automatically finds hidden patterns and relationships in the data.
It works in a way similar to how humans learn by observing without being taught.
The main goal of unsupervised learning is to discover the structure of the data, group similar
data, and sometimes reduce or compress the data.
Example: Grouping customers based on buying behavior without knowing their categories in
advance.
Why use Unsupervised Learning?
Below are some main reasons which describe the importance of Unsupervised Learning:
1. Unsupervised learning is helpful for finding useful insights from the data.
2. Unsupervised learning is much similar as a human learns to think by their own experiences,
which makes it closer to the real AI.
3. Unsupervised learning works on unlabeled and uncategorized data which make
unsupervised learning more important.
4. In real-world, we do not always have input data with the corresponding output so to solve
such cases, we need unsupervised learning.
Working Principle of Unsupervised Learning:
Fig. Unsupervised Learning
The working of unsupervised machine learning can be explained in these steps:
1. Collect Unlabeled Data
First, collect data that has no labels or names.
Example: Images of different animals like cows, horses, and camels without any tags or names.
pg. 12 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2. Select an Algorithm
Choose a suitable unsupervised learning algorithm based on the task.
Examples:
K-Means → to group similar animals
Apriori → to find relationships
PCA → to reduce data size
3. Train the Model on Raw Data
Give all the unlabeled data directly to the algorithm.
The algorithm studies the data to find similarities and patterns.
Example: - The model compares animal images based on shape, size, and features.
4. Group or Transform Data
The algorithm automatically:
Groups similar data into clusters, or
Finds hidden patterns, or
Reduces the number of features
Example: - Animals with similar features are grouped together, such as cows in one group and
horses in another.
5. Interpret and Use Results
Finally, analyze the results and use them for further work.
Example:
Understand different animal groups
Detect unusual animals
Use grouped data for visualization or other ML models
Types of Unsupervised Learning Algorithm:
• The unsupervised learning algorithm can be further categorized into two types as shown in Fig.
Fig. Types of Unsupervised Learning
pg. 13 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Clustering
Question - Define clustering. Explain in detail.
Defination: Clustering is an unsupervised learning technique that groups similar data points
together so that:
- Data within a cluster is highly similar
- Data in different clusters is dissimilar
Example: A shopping mall groups customers into different clusters based on their buying
habits without any labels.
Clustering analyzes the data to find common characteristics among data objects and groups
them based on these similarities.
It is the process of dividing a dataset into subsets, where each subset is called a cluster.
The collection of all clusters formed is called a clustering. Different clustering algorithms
may produce different cluster results for the same dataset.
The grouping is done automatically by clustering algorithms, not by humans. This helps in
This helps in discovering hidden patterns or unknown groups in the data.
Fig- Clustering
Types of Clustering:
Hard Clustering
Soft Clustering
Centroid-Based Clustering
Density-Based Clustering
Connectivity-Based (Hierarchical) Clustering
Distribution-Based Clustering
Fuzzy Clustering
Common Clustering Techniques
K-Means
DBSCAN
Mean-Shift
pg. 14 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Applications
Customer Segmentation: Grouping customers based on their behavior for better marketing
and services.
Anomaly Detection: Identifying unusual or fraudulent activities in finance, network security,
and sensor data.
Image Segmentation: Dividing images into meaningful parts for object detection and
medical analysis.
Recommendation Systems: Grouping user preferences to suggest suitable movies,
products, or content.
Market Basket Analysis: Finding products that are often bought together to improve store
layout and promotions.
Association
An association rule is an unsupervised learning method which is used for finding the
relationships between variables in the large database. It determines the set of items that
occurs together in the dataset.
Association rule makes marketing strategy more effective. Such as people who buy X item
(suppose a bread) are also tend to purchase Y (Butter/Jam) item. A typical example of
Association rule is Market Basket Analysis.
Dimensionality Reduction Technique
Question - Explain dimensionality reduction techniques.
Definition: Dimensionality Reduction is the process of reducing the number of features
(dimensions) in a dataset while retaining the most important and useful information.
In real-world machine learning problems, datasets often contain a very large number of
variables (features).
Handling such high-dimensional data becomes difficult for both humans and machines.
Dimensionality reduction helps simplify the dataset without losing its core meaning.
Purpose of Dimensionality Reduction
Reduce the number of features
Remove redundant and irrelevant variables
Improve learning efficiency of ML models
Reduce computation time and storage
Make data easier to visualize and interpret
Example: Email Spam Classification
In email spam classification, features like email subject and email body, text, links often give similar
information, so dimensionality reduction removes redundancy and keeps only the most useful
features for spam detection.
pg. 15 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Components of Dimensionality Reduction
Dimensionality reduction consists of two main components:
1. Feature Selection
Feature selection chooses a subset of original features and removes unnecessary ones.
It helps keep data meaningful while reducing size.
Example- For predicting house price, keep size and location, and remove owner’s favorite color
because it is unnecessary.
Methods:
1. Filter methods
2. Wrapper methods
3. Embedded methods
2. Feature Extraction
Feature extraction transforms original features into a new set of fewer features.
The new features represent important information from the original data.
Example: Math, Science, English-> Overall score
Types of Dimensionality Reduction Methods
Common methods:
Principal Component Analysis (PCA)
Linear Discriminant Analysis (LDA)
Generalized Discriminant Analysis (GDA)
Advantages of Dimensionality Reduction
1. Reduces storage requirements
2. Decreases computation time
3. Removes redundant and correlated features
Disadvantages of Dimensionality Reduction
1. Some information loss may occur
2. PCA captures only linear relationships
3. PCA may fail for complex datasets
4. Selecting the number of components can be difficult
pg. 16 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Reinforcement Learning
Question- What is reinforcement learning? How it works? Explain in detail.
Definition - Reinforcement learning trains an agent to make a sequence of decisions through
trial and error. The agent interacts with the environment, receives feedback in the form of
rewards or penalties and improves its performance over time
In reinforcement learning, the agent receives rewards for good actions and punishment for
bad actions. The main goal of the agent is to maximize the total reward.
In reinforcement learning, there is no labelled data like supervised learning, and agents
learn from their experiences only.
The reinforcement learning process is like a human, for example, a child learns various
things by experiences in his day-to-day life.
Example : Self Driving Car - The car’s AI system that decides what to do while driving.
It learns from trial and error using rewards and penalties and improves its driving policy over
time.
Components of Reinforcement Learning:
• Reinforcement Learning problems are typically modeled as a Markov Decision Process (MDP).
• Agent: The learner or decision-maker.
• Environment: Everything the agent interacts with.
• State (S): The current situation the agent is in.
• Action (A): The choices available to the agent in a given state.
• Reward (R): The immediate feedback after an action (positive = good, negative = bad).
• Policy (π): The strategy used by the agent to choose actions.
Concept of Agents, Rewards and Policy Learning in RL:
Reinforcement Learning (RL) is based on the interaction between an Agent and its Environment.
The agent takes actions, follows a policy, and receives rewards as feedback.
Fig. shows concept of RL. These three elements Agent, Reward and Policy form the foundation of
RL.
Fig. 1.13: Reinforcement Learning (RL)
pg. 17 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
How Reinforcement Learning Works
The Agent observes the current State
The Policy decides the Action
The Environment responds with a new State and a Reward
The Agent updates its Policy to get higher rewards in the future
This process repeats until the agent learns the best (optimal) policy.
Types of Reinforcement Learning
Positive Reinforcement: Rewards desired behavior
e.g., giving points for correct answers).
Negative Reinforcement: Removes negative outcomes to encourage good actions
e.g., turning off a buzzer after the right move
Advantages of Reinforcement Learning
1. Helps solve complex real-world problems
2. Learning process is similar to human learning
3. Useful for achieving long-term goals
Disadvantages of Reinforcement Learning
1. Not suitable for simple problems
2. Requires large data and high computation
3. Too many states can reduce performance
4. Curse of dimensionality limits its use in real systems
Question- Differentiate between Supervised, Unsupervised and Reinforcement Learning.
Comparison of different Types of ML with Real-World Applications
Feature Supervised Learning Unsupervised Learning Reinforcement Learning
Data Labeled data. Unlabeled data. Interaction data (trial and
Requirement error).
Goal Predict outcomes. Discover hidden patterns. Maximize long-term
reward.
Output Type Continuous (regression) Clusters, groups, latent features. Policy (best sequence of
/ Discrete (classification). actions).
Feedback Direct (knows correct None (no labels given). Indirect (reward signals).
answer).
Real-world E-mail spam filter, Customer segmentation, Self-driving cars, robotics,
Applications medical diagnosis, stock anomaly detection, product game-playing AI.
prediction. recommendations.
Strength High accuracy if data is Finds unknown patterns Learns sequential
labeled. automatically. decision-making.
Weakness Requires large labeled Results may be hard to interpret. Computationally
datasets. expensive, needs lots of
interactions.
pg. 18 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.3 Applications of ML- Real-world use cases of ML in various domains such as healthcare,
finance, e-commerce, etc, challenges in Machine Learning
Applications of Machine Learning
Question - Explain different applications of Machine Learning.
Machine Learning (ML) is one of the most exciting technologies today.
As the name suggests, it gives computers the ability to learn, which makes them behave more like
humans.
Because of this learning ability, machine learning is widely used in many real-world applications.
1. Healthcare
Machine learning is widely used in the healthcare industry to improve diagnosis, treatment, and
patient care.
Applications of ML in Healthcare:
(i) Drug Discovery - Machine learning analyzes large medical and chemical data to identify possible
drugs and predict how compounds will work against diseases.
(ii) Medical Imaging and Diagnostics - ML algorithms analyze medical images and detect patterns
that indicate diseases.
(iii) Disease Diagnosis - Machine learning helps identify diseases such as: Cancer, Heart disease,
Pneumonia
(iv) Medical Imaging - Deep learning detects tumors, fractures, and abnormalities in: X-rays, MRI
scans, CT scans
(v) Disease Prediction
ML models predict diseases like diabetes, cancer, and heart disease using patient records and
medical reports.
2. E-Commerce and Retail
Machine learning improves business performance in e-commerce and retail by enhancing user
experience and automating marketing tasks.
Applications of ML in E-Commerce:
(i) Demand Forecasting - ML predicts future product demand using past sales data, customer
behavior, and market trends.
(ii) Recommendation Systems- Machine learning suggests products or services based on:
User preferences
Past purchases
Website activity
(iii) Customer Segmentation- ML groups customers with similar behavior so businesses can
provide personalized services and offers.
pg. 19 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3. Finance- Machine learning plays an important role in the finance sector by improving security
and helping in better decision making.
Applications of ML in Finance:
(i) Fraud Detection- Machine learning detects fraudulent transactions by identifying unusual
spending patterns and suspicious activities.
(ii) Algorithmic Trading - ML analyzes large market data, predicts price movements, and performs
high-speed trading automatically.
(iii) Credit Scoring - Banks use ML models to evaluate whether a customer is eligible for a loan.
(iv) Risk Management - ML predicts risks related to investments, loans, and insurance policies.
Challenges in Machine Learning
Question - What are the challenges for Machine Learning?
Machine Learning (ML) has achieved great success in many fields, but it also faces several
challenges during development and real-world use.
These challenges mainly come from data issues, model problems, high computation needs, and
ethical concerns.
Understanding these challenges is important to build reliable, fair, and efficient ML systems.
1. Data-Related Challenges
Machine learning models depend heavily on data. If the data is poor, the model’s performance will
also be poor.
(a) Data Quality - ML models require high-quality data. Poor-quality data leads to wrong
predictions.
Problems in data quality include:
Missing values
Noisy or inconsistent data
Human errors in labeling
Example: A medical ML system trained on incorrect patient records may give wrong disease
diagnosis.
(b) Data Quantity - Many machine learning algorithms need large amounts of data to learn
properly.
Collecting large datasets can be costly and time-consuming
In fields like healthcare and space research, labeled data is difficult to obtain
(c) Data Imbalance- Sometimes, one class has much more data than another.
Example: Fraud detection systems have very few fraud cases compared to normal transactions.
This can cause the model to become biased and ignore rare cases.
pg. 20 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(d) Data Privacy and Security- Machine learning often uses personal data, such as:
Health records
Financial information
This creates privacy and security concerns.
Laws and regulations like GDPR and HIPAA restrict how data can be collected and used.
2. Algorithmic and Model Challenges: Choosing the right model is another major challenge in
machine learning.
Overfitting
Model becomes too complex
Learns noise instead of real patterns
Performs well on training data but poorly on new data
Underfitting
Model is too simple
Fails to capture important patterns
Performs poorly on both training and testing data
Example: A stock prediction model that only memorizes old prices fails when market conditions
change.
3. Computational Complexity : Modern ML models require high computational power.
Training deep learning models needs GPUs or TPUs
Large datasets increase time, cost, and energy usage
Small organizations may not afford such resources
4. Interpretability and Explainability : Many advanced ML models, especially deep learning
models, work like a black box.
It is difficult to understand how decisions are made
This is a serious problem in healthcare and finance
Explanations are required for trust, safety, and legal reasons
5. Generalization: Some ML models perform well during training but fail in real-world situations.
Example: A self-driving car trained in sunny weather may not work well in heavy rain or fog.
6. Ethical Considerations and Societal Impact : ML models can learn biases present in training
data.
This may lead to unfair decisions
Ethical issues affect trust and acceptance of ML systems
pg. 21 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.4 Introduction to Python for ML-Basics of Python programming relevant to ML, Overview
required libraries: NumPy, Pandas, Matplotlib, Scikit-learn, Writing and executing simple ML
scripts in Python
Python for ML-Basics of Python programming relevant to ML
Question - What is Python? Why it is used in Machine Learning?
Python is a high-level, interpreted, and open-source programming language that is easy to learn
and use. It supports multiple programming paradigms such as procedural, object-oriented, and
functional programming. Python is widely used for application development, data analysis,
artificial intelligence, and machine learning.
Why is Python used in Machine Learning?
Python is the most preferred language for Machine Learning due to the following reasons:
1. Simple and Easy Syntax: Python has a clear and readable syntax, which makes it easy to
write and understand ML programs.
2. Rich ML Libraries: Python provides powerful libraries for ML and data science:
o NumPy – numerical computations
o Pandas – data handling and analysis
o Matplotlib – data visualization
o Scikit-learn – ML algorithms
o TensorFlow / PyTorch – deep learning
3. Large Community Support: Python has a vast developer community, which helps in getting
tutorials, documentation, and ready-made solutions easily.
4. Platform Independent: Python programs can run on Windows, Linux, and macOS without
modification.
5. Easy Integration: Python can be easily integrated with other languages like C, C++, and Java
for performance-critical tasks.
6. Rapid Development: ML models can be developed and tested quickly using Python due to
fewer lines of code.
Overview required libraries: NumPy, Pandas, Matplotlib, Scikit-learn
Python Libraries for Machine Learning
Question - Explain NumPy, Pandas, Matplotlib and Scikit-learn with example
Python provides several powerful libraries that simplify the development of machine learning
models.
Some of the most important libraries are:
1. NumPy
2. Pandas
3. Matplotlib
4. Scikit-learn
pg. 22 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. NumPy (Numerical Python)
Purpose: NumPy is the fundamental library for numerical and scientific computing in Python.
Key Features:
Provides support for multi-dimensional arrays and matrices (ndarray)
Performs fast mathematical operations
Efficient memory usage compared to Python lists
Supports linear algebra, statistics, and random number generation
Why it is important in ML:
Machine learning algorithms rely heavily on numerical computations
Used for handling datasets, feature vectors, and mathematical formulas
Common Uses:
Array creation and manipulation
Matrix multiplication
Statistical operations (mean, variance, standard deviation)
Example:
import numpy as np
a = [Link]([1, 2, 3, 4])
print([Link]())
2. Pandas
Purpose: Pandas is used for data manipulation and data analysis.
Key Features:
Provides Series (1D) and DataFrame (2D) data structures
Easy handling of missing data
Powerful tools for data cleaning, filtering, and grouping
Supports reading and writing data from CSV, Excel, SQL, JSON, etc.
Why it is important in ML:
Real-world data is messy and unstructured
Pandas helps prepare data before applying ML algorithms
Common Uses:
Loading datasets
Data preprocessing
Feature engineering
Example:
import pandas as pd
df = pd.read_csv("[Link]")
print([Link]())
pg. 23 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3. Matplotlib
Purpose: Matplotlib is a data visualization library.
Key Features:
Creates static, animated, and interactive plots
Supports line graphs, bar charts, histograms, scatter plots, etc.
Customizable plots (labels, legends, colors)
Why it is important in ML:
Helps in understanding data patterns
Used for Exploratory Data Analysis (EDA)
Visualizes model performance and results
Common Uses:
Plotting trends
Visualizing distributions
Comparing predictions vs actual values
Example:
import [Link] as plt
[Link]([1, 2, 3], [4, 5, 6])
[Link]("X-axis")
[Link]("Y-axis")
[Link]()
4. Scikit-learn
Purpose: Scikit-learn is the most popular library for machine learning algorithms in Python.
Key Features:
Simple and consistent API
Supports supervised and unsupervised learning
Built-in tools for model evaluation and selection
Works seamlessly with NumPy and Pandas
Why it is important in ML:
Provides ready-to-use machine learning models
Eliminates the need to implement algorithms from scratch
Common Algorithms Available:
Linear Regression
Logistic Regression
Decision Trees
Random Forest
K-Means Clustering
Support Vector Machines (SVM)
pg. 24 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Example:
from sklearn.linear_model import LinearRegression
model = LinearRegression()
[Link](X_train, y_train)
Writing and executing simple ML scripts in Python
Question- List steps to Write and Execute Simple ML Scripts in Python
Steps:
1. Import required Python libraries.
2. Create or load the dataset.
3. Separate features (input) and target (output).
4. Select the machine learning model.
5. Train the model using training data.
6. Make predictions using the trained model.
7. Visualize the results (optional).
8. Save and execute the Python script.
Question- How to write and execute simple ML scripts in Python?
Writing and executing a simple Machine Learning (ML) script in Python involves a sequence of
well-defined steps. Python is widely used for ML because of its simplicity and availability of
powerful libraries.
Step 1: Import Required Libraries
Libraries provide ready-made functions that simplify ML development.
import numpy as np
import pandas as pd
import [Link] as plt
from sklearn.linear_model import LinearRegression
Step 2: Create or Load the Dataset
A dataset contains input features and corresponding output values.
data = {'Hours': [1, 2, 3, 4, 5],
'Marks': [35, 45, 55, 65, 75]}
df = [Link](data)
Step 3: Separate Features and Target
Features (X) are input variables and target (y) is the output variable.
X = df[['Hours']]
y = df['Marks']
pg. 25 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Step 4: Create and Train the ML Model
Here, a Linear Regression model is created and trained using the dataset.
model = LinearRegression()
[Link](X, y)
Step 5: Make Predictions
After training, the model predicts output for new input data.
prediction = [Link]([[6]])
print("Predicted Marks:", prediction)
Step 6: Visualize the Result (Optional)
Visualization helps understand the relationship between input and output.
[Link](X, y)
[Link](X, [Link](X))
[Link]("Study Hours")
[Link]("Marks")
[Link]()
Step 7: Execute the Python Script
1. Save the program as ml_script.py
2. Open Command Prompt / Terminal
3. Run the script using:
python ml_script.py
Advantages and disadvantages of ML
Advantages of Machine Learning
Automation of Repetitive Tasks
Improved Decision-Making
Identifies trends and enhances predictions
Continuous Improvement
Handles large datasets efficiently
Reduces operational expenses
Utilizes technological advancements
Disadvantages of Machine Learning
Requires high-quality data
High Computational Costs
Risk of Bias
Replaces repetitive tasks
pg. 26 Sutar Sir - 7385284210
Unit - I Introduction to Machine Learning CO-6K Machine Learning – 316316
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Assignment No-1
Unit - I Introduction to Machine Learning
1. Define Machine Learning. State its advantages and disadvantages.
2. With the help of diagram describe traditional programming approach.
3. Explain ML-based approaches with diagram.
4. Difference between Traditional programming vs ML-based approaches
5. What is the role of Machine Learning in artificial intelligence and data science?
6. List & Explain applications of Machine Learning in artificial intelligence and data science.
7. Write Difference between AI,ML & DS
8. Explain different types of Machine Learning
9. Differentiate/Comparison between Supervised, Unsupervised and Reinforcement Learning.
10. What is supervised machine learning? Describe with example. OR Explain working principle of
supervised machine learning
11. Explain classification in detail.
12. What is regression? Explain in detail.
13. What is unsupervised machine learning? Describe with example. OR Explain working principle of
unsupervised machine learning
14. Define clustering. Explain in detail.
15. Explain dimensionality reduction techniques.
16. What is reinforcement learning? How it works? Explain in detail.
17. Explain different applications of Machine Learning.
18. What are the challenges for Machine Learning?
19. What is Python? Why it is used in Machine Learning?
20. Explain NumPy, Pandas, Matplotlib and Scikit-learn with example.
21. How to write and execute simple ML scripts in Python?
pg. 27 Sutar Sir - 7385284210