Introduction to Machine
Learning
Unit I
Introduction to ML
Machine learning (ML) allows computers to learn and make decisions
without being explicitly programmed.
It involves feeding data into algorithms to identify patterns and make
predictions on new data.
It is used in various applications like image recognition, speech
processing, language translation, recommender systems, etc.
Why do we need Machine Learning?
Traditional programming requires exact instructions and doesn’t handle
complex tasks like understanding images or language well.
It can’t efficiently process large amounts of data. Machine Learning solves
these problems by learning from examples and making predictions without
fixed rules. Let's see various reasons why it is important:
1. Solving Complex Business Problems
2. Handling Large Volumes of Data
3. Automate Repetitive Tasks
4. Personalized User Experience
5. Self Improvement in Performance
What Makes a Machine "Learn"?
A machine "learns" by identifying patterns in data and improving its ability to perform specific
tasks without being explicitly programmed for every scenario. This learning process helps
machines to make accurate predictions or decisions based on the information they receive.
Unlike traditional programming where instructions are fixed, ML allows models to adapt and
improve through experience.
Here is how the learning process works:
Data Input: Machine needs data like text, images or numbers to analyze. Good quality and
enough quantity of data are important for effective learning.
Algorithms: Algorithms are mathematical methods that help the machine find patterns in
data. Different algorithms help different tasks such as classification or regression.
Model Training: During training, the machine adjusts its internal settings to better predict
outcomes. It learns by reducing the difference between its predictions and actual results.
Feedback Loop: Machine compares its predictions with true outcomes and uses this feedback
to correct errors. Techniques like gradient descent help it update and improve.
Experience and Iteration: Machine repeats training many times with data helps in refining its
predictions with each pass, more data and iterations improve accuracy.
Evaluation and Generalization: Model is tested on unseen data to ensure it performs well on
real-world tasks.
Machines "learn" by continuously increasing their understanding through data-driven iterations
like how humans learn from experience.
What is ML?
Machine learning is a branch of artificial intelligence that enables algorithms
to uncover hidden patterns within datasets. It allows them to predict new,
similar data without explicit programming for each task. Machine learning
finds applications in diverse fields such as image and speech recognition,
natural language processing, recommendation systems, fraud detection,
portfolio optimisation, and automating tasks.
Machine Learning Techniques
Handles Massive Data: Machine learning works well with large data and finds
patterns that humans might miss.
Adapts Dynamically: Systems evolve with new data, staying relevant in
changing environments.
Drives Smarter Decisions: From predicting customer behaviour to detecting
fraud, ML enhances decision-making with data-driven insights.
Personalises Experiences: Recommendation systems, like those on Netflix or
Amazon, tailor suggestions to individual preferences.
Types of ML
Machine learning is the branch of Artificial Intelligence that focuses on
developing models and algorithms that let computers learn from data
and improve from previous experience without being explicitly
programmed for every task. In simple words, ML teaches the systems
to think and understand like humans by learning from the data.
Machine learning is generally a training system to learn from past
experiences and improve performance over time. Machine
learning helps to predict massive amounts of data. It helps to deliver
fast and accurate results to get profitable opportunities.
Types of ML
There are several types of machine learning, each with special characteristics
and applications. Some of the main types of machine learning algorithms are
as follows:
Supervised Machine Learning
Unsupervised Machine Learning
Reinforcement Learning
Besides these three main types, modern machine learning also includes two
other important approaches: Self-Supervised Learning and Semi-Supervised
Learning.
semi-supervised learning, which combines elements of both supervised and
unsupervised learning.
Supervised Machine Learning
Supervised learning trains a model using labeled data where each input has a
known correct output. The model learns by comparing its predictions with
these correct answers and improves over time. It is used for
both classification and regression problems.
Example: Consider the following data regarding patients entering a clinic. The
data consists of the gender and age of the patients and each patient is
labeled as "healthy" or "sick".
Gender Age Label In this example, supervised learning is to use
this labeled data to train a model that can
M 48 sick
predict the label ("healthy" or "sick") for new
M 67 sick patients based on their gender and age. For
example if a new patient i.e Male with 50
F 53 healthy years old visits the clinic, model can classify
whether the patient is "healthy" or "sick"
M 49 sick
based on the patterns it learned during
F 32 healthy training.
M 34 healthy
M 21 healthy
Supervised learning is defined as when a model gets trained on a "Labelled Dataset".
Labelled datasets have both input and output parameters. In Supervised
Learning algorithms learn to map points between inputs and correct outputs. It has both
training and validation datasets labelled.
Let's understand it with the help of an example.
Example: Consider a scenario where you have to build an image classifier to
differentiate between cats and dogs. If you feed the datasets of dogs and cats labelled
images to the algorithm, the machine will learn to classify between a dog or a cat from
these labeled images. When we input new dog or cat images that it has never seen
before, it will use the learned algorithms and predict whether it is a dog or a cat. This is
how supervised learning works, and this is particularly an image classification.
categories of supervised learning
There are two main categories of supervised learning that are mentioned
below:
Classification
Regression
Classification
Classification deals with predicting categorical target variables, which
represent discrete classes or labels. For instance, classifying emails as spam
or not spam, or predicting whether a patient has a high risk of heart disease.
Classification algorithms learn to map the input features to one of the
predefined classes.
Here are some classification algorithms:
Logistic Regression
Support Vector Machine
Random Forest
Decision Tree
K-Nearest Neighbors (KNN)
Naive Bayes
Regression
Regression, on the other hand, deals with predicting continuous target
variables, which represent numerical values. For example, predicting the
price of a house based on its size, location, and amenities, or forecasting the
sales of a product. Regression algorithms learn to map the input features to a
continuous numerical value.
Here are some regression algorithms:
Linear Regression
Polynomial Regression
Ridge Regression
Lasso Regression
Decision tree
Random Forest
Advantages of Supervised Machine Learning
Supervised Learning models can have high accuracy as they are trained
on labelled data.
The process of decision-making in supervised learning models is often
interpretable.
It can often be used in pre-trained models which saves time and resources
when developing new models from scratch.
Disadvantages of Supervised Machine
Learning
It has limitations in knowing patterns and may struggle with unseen or
unexpected patterns that are not present in the training data.
It can be time-consuming and costly as it relies on labeled data only.
It may lead to poor generalizations based on new data.
Applications of Supervised Learning
Supervised learning is used in a wide variety of applications, including:
Image classification: Identify objects, faces, and other features in images.
Natural language processing: Extract information from text, such as sentiment, entities, and
relationships.
Speech recognition: Convert spoken language into text.
Recommendation systems: Make personalized recommendations to users.
Predictive analytics: Predict outcomes, such as sales, customer churn, and stock prices.
Medical diagnosis: Detect diseases and other medical conditions.
Fraud detection: Identify fraudulent transactions.
Autonomous vehicles: Recognize and respond to objects in the environment.
Email spam detection: Classify emails as spam or not spam.
Quality control in manufacturing: Inspect products for defects.
Credit scoring: Assess the risk of a borrower defaulting on a loan.
Gaming: Recognize characters, analyze player behavior, and create NPCs.
Customer support: Automate customer support tasks.
Weather forecasting: Make predictions for temperature, precipitation, and other meteorological
parameters.
Sports analytics: Analyze player performance, make game predictions, and optimize strategies.
Unsupervised Machine Learning
Unsupervised learning works with unlabeled data where no correct answers or
categories are provided. The model's job is to find the data, hidden patterns,
similarities or groups on its own. This is useful in scenarios where labeling
data is difficult or impossible. Common applications
are clustering and association.
Example: Consider the following data regarding patients. The dataset has a
unlabeled data where only the gender and age of the patients are available
Gender Age
with no health status labels.
Here unsupervised learning looks for patterns or groups within the data on its M 48
own. For example it might cluster patients by age or gender and grouping
M 67
them into categories like "younger healthy patients" or "older patients"
without knowing their health status. F 53
M 49
F 34
M 21
Unsupervised Learning Unsupervised learning is a type of machine learning
technique in which an algorithm discovers patterns and relationships
using unlabeled data. Unlike supervised learning, unsupervised learning doesn't
involve providing the algorithm with labeled target outputs. The primary goal of
Unsupervised learning is often to discover hidden patterns, similarities, or clusters
within the data, which can then be used for various purposes, such as data
exploration, visualization, dimensionality reduction, and more.
Let's understand it with the help of an example.
Example: Consider that you have a dataset that contains information about the
purchases you made from the shop. Through clustering, the algorithm can group
the same purchasing behavior among you and other customers, which reveals
potential customers without predefined labels. This type of information can help
businesses get target customers as well as identify outliers.
categories of unsupervised learning
There are two main categories of unsupervised learning that are mentioned
below:
Clustering
Association
Clustering
Clustering is the process of grouping data points into clusters based on their
similarity. This technique is useful for identifying patterns and relationships in
data without the need for labeled examples.
Here are some clustering algorithms:
K-Means Clustering algorithm
Mean-shift algorithm
DBSCAN Algorithm
Principal Component Analysis
Independent Component Analysis
Association
Association rule learning is a technique for discovering relationships between
items in a dataset. It identifies rules that indicate the presence of one item
implies the presence of another item with a specific probability.
Here are some association rule learning algorithms:
Apriori Algorithm
Eclat
FP-growth Algorithm
Advantages of Unsupervised Machine
Learning
It helps to discover hidden patterns and various relationships between the
data.
Used for tasks such as customer segmentation, anomaly detection, and data
exploration.
It does not require labeled data and reduces the effort of data labeling.
Disadvantages of Unsupervised Machine
Learning
Without using labels, it may be difficult to predict the quality of the model's
output.
Cluster Interpretability may not be clear and may not have meaningful
interpretations.
It has techniques such as autoencoders and dimensionality reduction that can
be used to extract meaningful features from raw data.
Applications of Unsupervised Learning
Here are some common applications of unsupervised learning:
Clustering: Group similar data points into clusters.
Anomaly detection: Identify outliers or anomalies in data.
Dimensionality reduction: Reduce the dimensionality of data while preserving its essential information.
Recommendation systems: Suggest products, movies, or content to users based on their historical
behavior or preferences.
Topic modeling: Discover latent topics within a collection of documents.
Density estimation: Estimate the probability density function of data.
Image and video compression: Reduce the amount of storage required for multimedia content.
Data preprocessing: Help with data preprocessing tasks such as data cleaning, imputation of missing
values, and data scaling.
Market basket analysis: Discover associations between products.
Genomic data analysis: Identify patterns or group genes with similar expression profiles.
Image segmentation: Segment images into meaningful regions.
Community detection in social networks: Identify communities or groups of individuals with similar
interests or connections.
Customer behavior analysis: Uncover patterns and insights for better marketing and product
recommendations.
Content recommendation: Classify and tag content to make it easier to recommend similar items to
users.
Exploratory data analysis (EDA): Explore data and gain insights before defining specific tasks.
Reinforcement Machine Learning
Reinforcement Learning (RL) trains an agent to make decisions by interacting
with an environment. Instead of being told the correct answers, agent learns
by trial and error method and gets rewards for good actions and penalties for
bad ones. Over time it develops a strategy to maximize rewards and achieve
goals. This approach is good for problems having sequential decision making
such as robotics, gaming and autonomous systems.
Example: While Identifying a Fruit, system receives an input for example an
apple and initially makes an incorrect prediction like "It's a mango". Feedback
is provided to correct the error "Wrong! It's an apple" and the system updates
its model based on this feedback.
Over time it learns to respond correctly that "It's an apple" when getting
similar inputs and also improves accuracy.
Reinforcement machine learningalgorithm is a learning method that interacts
with the environment by producing actions and discovering errors.
Trial, error, and delay are the most relevant characteristics of reinforcement
learning. In this technique, the model keeps on increasing its performance
using Reward Feedback to learn the behavior or pattern.
These algorithms are specific to a particular problem e.g. Google Self Driving
car, AlphaGo where a bot competes with humans and even itself to get better
and better performers in Go Game.
Each time we feed in data, they learn and add the data to their knowledge
which is training data. So, the more it learns the better it gets trained and
hence experienced.
Here are some of most common reinforcement learning algorithms:
Q-learning: Q-learning is a model-free RL algorithm that learns a Q-function,
which maps states to actions. The Q-function estimates the expected reward
of taking a particular action in a given state.
SARSA (State-Action-Reward-State-Action): SARSA is another model-free RL
algorithm that learns a Q-function. However, unlike Q-learning, SARSA
updates the Q-function for the action that was actually taken, rather than the
optimal action.
Deep Q-learning: Deep Q-learning is a combination of Q-learning and deep
learning. Deep Q-learning uses a neural network to represent the Q-function,
which allows it to learn complex relationships between states and actions.
Let's understand it with the help of examples.
Example: Consider that you are training an AI agent to play a game like chess.
The agent explores different moves and receives positive or negative
feedback based on the outcome. Reinforcement Learning also finds
applications in which they learn to perform tasks by interacting with their
surroundings.
Types of Reinforcement Machine Learning
There are two main types of reinforcement learning:
Positive reinforcement
Rewards the agent for taking a desired action.
Encourages the agent to repeat the behavior.
Examples: Giving a treat to a dog for sitting, providing a point in a game for a
correct answer.
Negative reinforcement
Removes an undesirable stimulus to encourage a desired behavior.
Discourages the agent from repeating the behavior.
Examples: Turning off a loud buzzer when a lever is pressed, avoiding a penalty by
completing a task.
Advantages of Reinforcement Machine
Learning
It has autonomous decision-making that is well-suited for tasks and that can
learn to make a sequence of decisions, like robotics and game-playing.
This technique is preferred to achieve long-term results that are very difficult
to achieve.
It is used to solve a complex problems that cannot be solved by conventional
techniques.
Disadvantages of Reinforcement Machine
Learning
Training Reinforcement Learning agents can be computationally expensive and
time-consuming.
Reinforcement learning is not preferable to solving simple problems.
It needs a lot of data and a lot of computation, which makes it impractical
and costly.
Applications of Reinforcement Machine
Learning
Here are some applications of reinforcement learning:
Game Playing: RL can teach agents to play games, even complex ones.
Robotics: RL can teach robots to perform tasks autonomously.
Autonomous Vehicles: RL can help self-driving cars navigate and make decisions.
Recommendation Systems: RL can enhance recommendation algorithms by learning user preferences.
Healthcare: RL can be used to optimize treatment plans and drug discovery.
Natural Language Processing (NLP): RL can be used in dialogue systems and chatbots.
Finance and Trading: RL can be used for algorithmic trading.
Supply Chain and Inventory Management: RL can be used to optimize supply chain operations.
Energy Management: RL can be used to optimize energy consumption.
Game AI: RL can be used to create more intelligent and adaptive NPCs in video games.
Adaptive Personal Assistants: RL can be used to improve personal assistants.
Virtual Reality (VR) and Augmented Reality (AR): RL can be used to create immersive and interactive
experiences.
Industrial Control: RL can be used to optimize industrial processes.
Education: RL can be used to create adaptive learning systems.
Agriculture: RL can be used to optimize agricultural operations.
Difference between ML, AI
Artificial Intelligence Machine Learning
AI is a broader field focused on creating systems that mimic human intelligence, ML is a subset of AI that focuses on teaching machines to learn patterns from data
including reasoning, decision-making, and problem-solving. and improve over time without explicit programming
The main goal of AI is to develop machines that can perform complex tasks ML focuses on finding patterns in data and using them to make predictions or
intelligently, similar to how humans think and act. decisions. It aims to help systems improve automatically with experience.
AI systems aim to simulate human intelligence and can perform tasks across
ML focuses on training systems for specific tasks, such as prediction or classification.
multiple domains.
AI aims to create systems that can think, learn, and make decisions ML aims to create systems that learn from data and improve their performance for a
autonomously. particular task.
AI has a wider application range, including problem-solving, decision-making, and ML applications are typically narrower, focused on tasks like pattern recognition and
autonomous systems predictive modeling.
AI can operate with minimal human intervention, depending on its complexity ML requires human involvement for data preparation, model training, and
and design. optimization
AI produces intelligent behavior, such as driving safely, responding to customer ML generates predictions or classifications based on data, such as predicting house
queries, or diagnosing diseases, and can adapt to changing scenarios. prices, identifying objects in images, or categorizing emails.
AI involves broader goals, including natural language processing, vision, and ML focuses specifically on building models that identify patterns and relationships in
reasonin data
Examples: Robotics, virtual assistants like Siri, autonomous vehicles, and Examples: Recommender systems, fraud detection, stock price forecasting, and
intelligent chatbots. social media friend suggestions.
ML project life cycle
The machine learning lifecycle includes:
Defining the Problem: Clearly identify the real-world problem to be solved.
Data Collection: Gather necessary data from various sources.
Data Cleaning and Pre-processing: Resolve data quality issues and prepare the data for
analysis.
Exploratory Data Analysis (EDA): Analyse data to identify patterns, outliers, and
trends.
Feature Engineering and Selection: Enhance data features and select relevant ones to
improve model performance.
Model Selection: Choose suitable models based on the problem type and data
characteristics.
Model Training: Train the model using a split of training and validation datasets.
Model Evaluation and Tuning: Assess and optimize the model using relevant metrics.
Model Deployment: Implement the model in a production environment for real-time
predictions.
Model Monitoring and Maintenance: Regularly check and update the model to maintain
accuracy.
Applications of ML
Machine learning continues to evolve which helps in opening new possibilities
and transforming industries by helping smarter, data-driven decisions and
automation which was not possible earlier.
Machine Learning (ML) is one of the most significant advancements in the
field of technology. It gives machines the ability to learn from data and
improve over time without being explicitly programmed. ML models identify
patterns from data and use them to make predictions or decisions.
Organizations use machine learning to automate tasks, make smarter
decisions and gain valuable insights. ML is shaping the world around us. Here
are few real-world applications of Machine Learning:
1. Healthcare and Medical Diagnosis
ML algorithms can analyze large volumes of patient data, medical scans and
genetic information to aid in diagnosis and treatment.
Applications:
Disease Detection: ML models are used to identify diseases like cancer,
pneumonia and Parkinson’s from medical images. They often achieve accuracy
comparable to or better than human doctors.
Predictive Analytics: By analyzing patient history and symptoms, models can
predict the risk of certain diseases or potential complications.
Drug Discovery: ML accelerates the drug development process by predicting
how different compounds will interact, reducing the time and cost of
research.
2. Smart Assistants and Human-Machine
Interaction
Virtual assistants systems rely on natural language processing
(NLP) and speech recognition to understand commands and respond
intelligently.
Applications:
Voice Assistants: Tools like Siri, Alexa and Google Assistant convert spoken
input into actionable commands.
Voice Search & Transcription: ML enables users to perform hands-free web
searches and get transcription during meetings or phone calls.
Chatbots: Businesses use AI-powered chatbots for 24/7 customer support,
helping resolve queries faster and more efficiently.
3. Personalized Recommendations and User
Experience
Modern digital platforms uses personalization which is done by
using recommender systems. Machine learning models analyze user behavior
to deliver relevant content, improving engagement and satisfaction.
Applications:
Streaming Platforms: Netflix and Spotify suggest shows and songs based on
your watching or listening history.
E-commerce: Sites like Amazon recommend products tailored to your
preferences, browsing patterns and past purchases.
Social Media: Algorithms curate content feeds, prioritize posts and suggest
friends or pages.
These systems use techniques like collaborative filtering and content-based
filtering to create personalized digital experiences.
4. Fraud Detection and Financial
Forecasting
In finance, vast sums of money move digitally and machine learning plays a
important role in fraud detection and market analysis.
Applications:
Transaction Monitoring: Banks use ML models to detect unusual spending
behavior and flag suspicious transactions.
Loan Risk Assessment: Credit scoring models analyze customer profiles and
predict the likelihood of default.
Stock Market Prediction: ML is used to analyze historical stock data and
forecast price movements. Stock markets are complex, algorithmic trading
uses these predictions for better decision-making.
5. Autonomous Vehicles and Smart Mobility
Self-driving vehicles use ML to understand their environment, navigate safely
and make immediate decisions.
Key Components:
Computer Vision: Recognizing lanes, pedestrians, traffic signals and obstacles.
Sensor Fusion: Combining data from cameras, LiDAR and radar for a 360-
degree view.
Behavior Prediction: Anticipating how other drivers or pedestrians may act.
Autonomous vehicles are capable of operating with minimal human input.
Beyond cars, ML is also being used in traffic optimization, smart navigation
systems and predictive maintenance in transportation.