SEng5305-chap-1-Introduction To ML
SEng5305-chap-1-Introduction To ML
Instructor
Dr.T.Gopi Krishna
Associate Professor, Department of CSE
ASTU
Email: [email protected] Contact No.0904433041 B509-R9
(SEng5305) Course Objectives
1. Understand the core principles of machine learning, including the distinction between supervised, unsupervised, and reinforcement
learning.
2. Apply key machine learning algorithms, such as linear regression, decision trees, support vector machines, k-means clustering, and
neural networks.
3. Analyze proficiency in data cleaning, feature selection, and data transformation techniques to prepare datasets for machine learning
models.
4. Understand techniques to evaluate model performance using metrics like accuracy, precision, recall, and F1-score, and apply
methods like cross-validation to optimize models.
5. Learn strategies to handle overfitting and underfitting by tuning hyperparameters, using regularization techniques, and
understanding the bias-variance trade-off.
6. Understand and experience in building machine learning models using real-world datasets across different domains like healthcare,
finance, and e-commerce.
7. Develop proficiency in popular machine learning frameworks and libraries such as scikit-learn, TensorFlow, and Keras, as well as
tools like Jupyter Notebooks for model development and experimentation.
8. Apply machine learning techniques to solve practical problems, build predictive models, and make data-driven decisions in various
application domains.
9. Grasp solid foundation for advanced courses in data science, artificial intelligence, deep learning, and related fields
Prerequisites:
Proficiency in programming (Python recommended).
(SEng5305) Course Description
This course provides a comprehensive introduction to the fundamental concepts and
techniques of Machine Learning (ML). Students will explore both theoretical
foundations and practical applications of machine learning algorithms. The course covers
key topics such as supervised learning (classification, regression), unsupervised learning
(clustering, dimensionality reduction), and reinforcement learning. The course is designed
to equip students with the skills to build and evaluate machine learning models,
understand their real-world applications, and address challenges such as overfitting and
bias-variance trade-off. Students will gain hands-on experience through coding and
implementing algorithms using tools like Python and libraries such as scikit-learn and
TensorFlow..
(SEng5305) Learning Objectives
By the end of the course, students will be able to:
• Understand the fundamental concepts of machine learning, including supervised,
unsupervised, reinforcement learning and deep learning.
• Develop proficiency in designing, implementing, and evaluating machine learning
models for real-world engineering problems.
• Apply advanced optimization techniques to solve machine learning problems
efficiently.
• Learn the theoretical foundations of machine learning algorithms and their
limitations.
• Gain experience with popular machine learning libraries and frameworks like Scikit-
learn and TensorFlow.
• Understand and apply various machine learning algorithms.
• Analyze data and develop predictive models.
• Work with real-world datasets to solve practical problems.
• Evaluate model performance and optimize model parameters.
(SEng5305) Chapter-1 Introduction To Machine Learning
What is ML?
Machine learning is a subset of artificial intelligence (AI)
that focuses on the development of algorithms and
statistical models that enable computers to perform tasks
without explicit programming instructions. (by Arthur Lee
Samuel )
A computer program which learns from experience is
called a machine learning program or simply a learning
program.
It is concerned with the creation of systems that can
automatically learn and improve from experience or data,
rather than relying solely on human intervention or
predefined rules.
In essence, machine learning algorithms allow computers
to recognize patterns, make predictions, and adapt their
behavior based on empirical evidence or observations.
v Machine Learning is making the computer learn from
studying data and statistics.
v Machine Learning is a program that analyses data and
learns to predict the outcome.
History of Machine Learning
While the concept has been around for decades, significant advancements have
been made in recent years due to increased computational power, larger datasets,
and the development of new algorithms.
Early Beginnings (1950s-1960s)
Perceptron:- Frank Rosenblatt introduced the perceptron, a simple neural network
model capable of learning from examples.(Supervised Learning especially)
Artificial Neural Networks:- Inspired by the human brain, researchers began
exploring artificial neural networks as a potential approach to machine learning.
AI Winter (1970s-1980s)
Limitations:- Early AI systems faced limitations in terms of computational power
and the availability of large datasets, leading to a period of decreased funding and
interest.
ML History Contd…
Resurgence (1990s-2000s)
Support Vector Machines (SVMs):- SVMs were developed as a powerful tool for
classification and regression tasks.
Decision Trees and Random Forests:- These ensemble methods became popular for their
interpretability and accuracy.
Neural Networks Revisited:- Advances in hardware and algorithms led to a resurgence
of interest in neural networks, particularly in the form of deep learning.
Deep Learning Revolution (2010s-Present)
Deep Neural Networks:- Deep learning architectures with multiple layers of neurons
have achieved remarkable success in various domains, including image recognition,
natural language processing, and speech recognition.
Convolutional Neural Networks (CNNs):- CNNs are specifically designed for
processing image data and have revolutionized computer vision tasks.
Recurrent Neural Networks (RNNs):- RNNs are well-suited for sequential data, such as
text and time series, and have been applied to tasks like machine translation and language
modeling.
ML History contd.. Key milestones in recent years
include:
ImageNet Challenge:- Competitions like ImageNet have spurred the development
of deep learning models for object recognition and classification.
AlphaGo:- DeepMind's AlphaGo defeated world champion Go player Lee Sedol in
2016, demonstrating the power of deep reinforcement learning.
Generative Adversarial Networks (GANs):- GANs have been used to generate
realistic images, videos, and other forms of data.
Today, machine learning is at the forefront of AI research, with applications in
various domains, including robotics, healthcare, finance, and more. Ongoing
research focuses on ethical AI, interpretability of machine learning models,
and advancements in unsupervised learning and transfer learning.
Currently, machine learning is a rapidly evolving field with applications in
various industries, and finance to autonomous vehicles and entertainment. As
technology continues to advance, we can expect even more exciting
developments in machine learning in the years to come.
Terminologies of Machine Learning
• Model: A model is a specific representation learned from data by applying some
machine learning algorithm. A model is also called a hypothesis.
• Feature: A feature is an individual measurable property of our data. A set of numeric
features can be conveniently described by a feature vector. Feature vectors are fed as
input to the model. For example, in order to predict a fruit, there may be features like
color, smell, taste, etc. Note: Choosing informative, discriminating and independent
features is a crucial step for effective algorithms. We generally employ a feature
extractor to extract the relevant features from the raw data.
• Target (Label): A target variable or label is the value to be predicted by our model. For
the fruit example discussed in the features section, the label with each set of input would
be the name of the fruit like apple, orange, banana, etc.
• Training: The idea is to give a set of inputs(features) and its expected outputs(labels), so
after training, we will have a model (hypothesis) that will then map new data to one of
the categories trained on.
• Prediction: Once our model is ready, it can be fed a set of inputs to which it will provide
a predicted output(label). But make sure if the machine performs well on unseen data,
then only we can say the machine performs well.
Training and Prediction
Features of Machine learning
• Machine learning is data driven technology. Large amount of data
generated by organizations on daily bases. So, by notable relationships
in data, organizations makes better decisions.
• Machine can learn itself from past data and automatically improve.
• From the given dataset it detects various patterns on data.
• For the big organizations branding is important and it will become more
easy to target relatable customer base.
• It is similar to data mining because it is also deals with the huge
amount of data.
Ability to Learn from Data, Adaptability and Flexibility, Scalability, Pattern
Recognition, Continuous Improvement, Handling Complex and Nonlinear
Relationships, Data-Driven Decisions, Multidomain Applicability, Handling
Multidimensional and Multivariable Data, Real-Time Processing and Prediction,
etc..,
Importance of Machine Learning
• ML is important for several reasons, particularly in today’s data-driven world,
where massive amounts of information are generated. Machine learning is
reshaping industries by driving efficiency, improving accuracy, and enabling the
creation of intelligent systems that can learn and evolve over time. Here are key
reasons why ML is critical:
• Automation of Tasks: Machine learning enables automation of tasks that are
traditionally performed by humans, leading to increased efficiency, productivity, and
scalability across various domains. By automating repetitive tasks and decision-making
processes, machine learning systems free up human resources to focus on higher-value
activities.
• Data-driven Insights: Machine learning algorithms analyze large volumes of data to
extract meaningful insights and patterns that may not be apparent to human analysts.
These insights drive data-driven decision-making, enabling organizations to gain
competitive advantages, optimize processes, and identify new business opportunities.
• Handling Large Volumes of Data:-ML algorithms can handle and analyze large datasets,
finding patterns and insights that are difficult for humans to detect.
Importance of Machine Learning contd..
• Predictive Analytics: Machine learning enables predictive analytics by building models
that forecast future outcomes based on historical data. Predictive models are used in
finance, healthcare, marketing, and other domains to anticipate customer behavior,
identify risks, detect anomalies, and optimize resource allocation.
• Enhanced Customer Experience: Machine learning algorithms improve customer
experience by enabling personalized interactions, efficient customer support, and
anticipatory services. Chatbots, virtual assistants, and recommendation systems
leverage machine learning to provide timely and relevant responses to customer inquiries
and preferences.
• Healthcare Advancements: In healthcare, machine learning is revolutionizing disease
diagnosis, treatment planning, and drug discovery. Machine learning algorithms
analyze medical images, genomic data, electronic health records (EHRs), and wearable
sensor data to assist physicians in early disease detection, treatment selection, and
patient monitoring.
• Enhanced Accuracy and Efficiency
ML improves the accuracy of tasks like image recognition, language translation, and
medical diagnoses.
Importance of Machine Learning contd..
• Fraud Detection and Cybersecurity: Machine learning plays a crucial role in fraud
detection and cybersecurity by identifying suspicious activities, detecting anomalies,
and mitigating security threats in real-time. Machine learning algorithms analyze large-
scale datasets to distinguish between normal and fraudulent behavior, reducing financial
losses and protecting sensitive information.
• Autonomous Systems: Machine learning enables the development of autonomous
systems such as self-driving cars, drones, and robots. These systems leverage sensor
data, computer vision, and reinforcement learning algorithms to perceive their
environment, make decisions, and navigate complex scenarios without human
intervention.
• Adaptability
Unlike traditional software, ML models can continuously improve and adapt by learning
from new data.
• Solving Complex Problems
ML allows us to tackle complex problems that are not solvable with simple rule-based
programming. For example, predicting climate change, drug discovery, and understanding
natural language require sophisticated, data-driven approaches that ML can offer.
Importance of Machine Learning contd..
• Scientific Discoveries: Machine learning accelerates scientific discoveries by
analyzing large datasets, simulating complex systems, and identifying novel
patterns or correlations. Machine learning techniques are used in various scientific
disciplines, including astronomy, genomics, climate science, and materials
science, to advance research and exploration.
• Continuous Improvement: Machine learning models can continuously learn and
improve over time by incorporating new data and feedback. This iterative process,
known as model retraining or online learning, ensures that machine learning
systems remain adaptive and responsive to evolving circumstances, leading to
ongoing performance enhancements and innovation.
• Improved Decision Making
ML models can be trained to make data-driven decisions. For instance, in finance,
ML helps in credit scoring and fraud detection by analyzing complex data patterns,
allowing businesses to make better, faster decisions.
• Cost-Effectiveness, Enabling Innovation etc…,
Applications of Machine Learning in Engineering
• Predictive Maintenance: ML models analyze sensor data from machinery to
predict when equipment is likely to fail, enabling proactive maintenance and
minimizing downtime.
• Quality Control and Defect Detection: ML algorithms detect defects in
manufactured products by analyzing images, sensor data, or process parameters,
ensuring product quality and reducing waste.
• Supply Chain Optimization: ML optimizes supply chain operations by predicting
demand, optimizing inventory levels, and improving logistics and distribution
efficiency.
• Energy Management: ML algorithms optimize energy consumption in buildings,
industrial processes, and renewable energy systems by analyzing data and
identifying opportunities for energy savings.
ML Applications contd..
• Structural Health Monitoring: ML techniques analyze structural data from
sensors to detect anomalies, assess structural integrity, and predict maintenance
needs for bridges, buildings, and infrastructure.
• Smart Grids and Power Systems: ML models optimize power generation,
distribution, and consumption in smart grids by forecasting energy demand,
managing grid stability, and integrating renewable energy sources.
ML Applications contd..
• Health Monitoring and Biomedical Engineering: ML algorithms analyze
medical data, including electronic health records, medical images, and genomic
data, to assist in disease diagnosis, treatment planning, and personalized medicine.
• Environmental Monitoring: ML techniques analyze environmental data, such as
air quality, water quality, and weather patterns, to monitor environmental
conditions, predict natural disasters, and support environmental conservation
efforts.
• Process Optimization: ML optimizes industrial processes, chemical processes,
and manufacturing operations by identifying inefficiencies, optimizing
parameters, and improving productivity.
Machine Learning lifecycle
Here are the steps to get started with machine
learning Life cycle
ML Life Cycle Steps contd..
The lifecycle of a machine learning project involves a series of steps that include:
• Study the Problems: The first step is to study the problem. This step involves
understanding the business problem and defining the objectives of the model.
• Data Collection: When the problem is well-defined, we can collect the relevant data
required for the model. The data could come from various sources such as databases,
APIs, or web scraping.
• Data Preparation: When our problem-related data is collected. then it is a good idea to
check the data properly and make it in the desired format so that it can be used by the
model to find the hidden patterns. This can be done in the following steps:
• Data cleaning
• Data Transformation
• Explanatory Data Analysis and Feature Engineering
• Split the dataset for training and testing.
ML Life Cycle Steps
Splitting data into training and test sets is a crucial step in machine learning to evaluate the
performance of your model. Here's how you can do it:
• Import your dataset: First, load your dataset into your machine learning environment.
This dataset should contain the features (independent variables) and the corresponding
target variable (dependent variable) that you want to predict.
• Divide the dataset: Split your dataset into two parts: the training set and the test set. The
training set will be used to train your model, while the test set will be used to evaluate its
performance.
• Randomization (optional): Before splitting, it's often a good practice to shuffle your
dataset to ensure that the data points are not ordered in any particular way. This helps to
prevent any bias that might arise if the data has a specific order.
• Split the dataset: Decide on a ratio for splitting your dataset into training and test sets. A
common ratio is 70-30 or 80-20, where 70% or 80% of the data is used for training and
the remaining 30% or 20% is used for testing. You can also use cross-validation
techniques for more robust evaluation.
Splitting code example in Python:
from sklearn.model_selection import
train_test_split
Machine learning encompasses a wide range of problems, datasets, and tools that
are used for various applications.
• Classification: Assigning categories or labels to input data based on past
observations. Example: Spam email detection.
• Regression: Predicting continuous values based on input features. Example:
Predicting house prices.
• Clustering: Grouping similar data points together based on their characteristics.
Example: Customer segmentation.
• Anomaly Detection: Identifying outliers or unusual patterns in data. Example:
Fraud detection.
Machine Learning Problems Contd..
• Dimensionality Reduction: Reducing the number of input features while
preserving important information. Example: Principal Component Analysis
(PCA).
• Recommendation Systems: Predicting user preferences or recommendations
based on historical data. Example: Movie or product recommendations.
• Natural Language Processing (NLP): Analyzing and understanding human
language data. Example: Sentiment analysis.
• Time Series Forecasting: Predicting future values based on historical time-
stamped data. Example: Stock price prediction.
• Reinforcement Learning: Teaching agents to take actions in an environment to
maximize rewards. Example: Game playing agents.
Data in Machine Learning
Data is typically divided into two types:
• Labeled data
• Unlabeled data
How do we split data in Machine Learning?
• Training Data: The part of data we use to train our model. This is the data that your
model actually sees(both input and output) and learns from.
• Validation Data: The part of data that is used to do a frequent evaluation of the model,
fit on the training dataset along with improving involved hyperparameters (initially set
parameters before the model begins learning). This data plays its part when the model is
actually training.
• Testing Data: Once our model is completely trained, testing data provides an unbiased
evaluation. When we feed in the inputs of Testing data, our model will predict some
values(without seeing actual output). After prediction, we evaluate our model by
comparing it with the actual output present in the testing data. This is how we evaluate
and see how much our model has learned from the experiences feed in as training data,
set at the time of training.
Datasets Examples
• MNIST: A dataset of handwritten digits widely used for classification tasks.
• CIFAR-10/100: Datasets of images categorized into 10 or 100 classes, commonly used for image
classification.
• IMDB: A dataset of movie reviews labeled as positive or negative sentiment, often used for sentiment
analysis.
• UCI Machine Learning Repository: A collection of various datasets covering different domains and
problems.
• Titanic Dataset: A dataset containing information about passengers aboard the Titanic, commonly used
for classification and survival prediction.
• Enron Email Dataset: A dataset of emails from the Enron Corporation, often used for text mining and
NLP tasks.
• Boston Housing Dataset: A dataset containing information about housing prices in Boston, commonly
used for regression tasks.
• Most widely used open source dataset in online by students and researchers : Kaggle
Kaggle: Many datasets are freely accessible for learning and experimentation. Kaggle datasets can vary
widely in terms of size, complexity, and application domain, including fields such as finance, healthcare,
image recognition, natural language processing, and more. The datasets are typically preprocessed and
organized into structured formats like CSV, Excel, or JSON. Datasets range from small to large-scale,
covering different real-world and synthetic problems.
Machine Learning Tools & Frameworks Using in
Python
• Scikit-learn: A popular Python library for machine learning tasks such as
classification, regression, clustering, and dimensionality reduction.
• TensorFlow: An open-source machine learning framework developed by
Google for building and training neural networks.
• PyTorch: A deep learning library developed by Facebook's AI Research lab,
known for its dynamic computation graph.
• Keras: A high-level neural networks API written in Python, compatible with
TensorFlow, Theano, and Microsoft Cognitive Toolkit.
• Pandas: A Python library for data manipulation and analysis, widely used for
data preprocessing and exploration.
Machine Learning Tools contd..
• NumPy: A fundamental package for scientific computing in Python, providing
support for multidimensional arrays and matrices.
• Matplotlib and Seaborn: Python libraries for data visualization, used for
creating plots, charts, and graphs.
• Jupyter Notebooks: An interactive computing environment that allows users to
create and share documents containing live code, visualizations, and narrative text.
• XGBoost and LightGBM: Libraries for gradient boosting, commonly used for
classification and regression tasks.
• NLTK (Natural Language Toolkit): A Python library for NLP tasks such as
tokenization, stemming, and parsing.
Types of Machine Learning
§ Supervised and Semi-SL Machine Learning
§ Unsupervised Machine Learning
§ Reinforcement Machine Learning
§ Deep Learning
Supervised Learning
Supervised learning is a type of machine learning in which the algorithm is
trained on the labeled dataset. It learns to map input features to targets based on
labeled training data. In supervised learning, the algorithm is provided with input
features and corresponding output labels, and it learns to generalize from this data
to make predictions on new, unseen data.
Supervised Learning Model Contd..
The model or algorithm is presented with example inputs and their desired outputs
and then finds patterns and connections between the input and the output. The goal
is to learn a general rule that maps inputs to outputs. The training process
continues until the model achieves the desired level of accuracy on the training
data.
Some real-life examples are:
Image Classification: You train with images/labels. Then in the future, you give a new
image expecting that the computer will recognize the new object.
Market Prediction/Regression: You train the computer with historical market data and ask
the computer to predict the new price in the future.
Two most common usecases of Supervised
learning are: (Types of Supervised Learning)
• Classification: Inputs are divided into two or more classes, and the learner must produce
a model that assigns unseen inputs to one or more (multi-label classification) of these
classes and predicts whether or not something belongs to a particular class. This is
typically tackled in a supervised way. Classification models can be categorized in two
groups: Binary classification and Multiclass Classification. Spam filtering is an
example of binary classification, where the inputs are email (or other) messages and the
classes are “spam” and “not spam”. Iris dataset for multiclass classification.
• Regression: It is also a supervised learning problem, that predicts a numeric value and
outputs are continuous rather than discrete. For example, predicting stock prices using
historical data.
Dataset Example for SL
Example — Consider the following data regarding patients Gender Age Label
entering a clinic . The data consists of the gender and age of the
patients and each patient is labeled as “healthy” or “sick”. M 48 sick
M 67 sick
F 53 healthy
M 49 sick
F 32 healthy
M 34 healthy
M 21 healthy
Examples of Labeled data sets
Labeled Dataset Explanation
• Figure A: It is a dataset of a shopping store that is useful in predicting whether a
customer will purchase a particular product under consideration or not based on
his/her gender, age, and salary.
Input: Gender, Age, Salary
Output: Purchased i.e. 0 or 1; 1 means yes the customer will purchase
and 0 means that the customer won’t purchase it.
• Figure B: It is a Meteorological dataset that serves the purpose of predicting wind
speed based on different parameters.
Input: Dew Point, Temperature, Pressure, Relative Humidity, Wind Direction
Output: Wind Speed
Training the system Using SL
While training the model, data is usually split in the ratio of 80:20 i.e. 80% as
training data and the rest as testing data. In training data, we feed input as well as
output for 80% of data. The model learns from training data only. We use different
machine learning algorithms(which we will discuss in detail in the next chapters) to
build our model. Learning means that the model will build some logic of its own.
Once the model is ready then it is good to be tested. At the time of testing, the input
is fed from the remaining 20% of data that the model has never seen before, the
model will predict some value and we will compare it with the actual output and
calculate the accuracy.
Algorithms Used in Supervised Learning
• Linear Regression
Linear regression is a type of regression algorithm that is used to predict a
continuous output value. It is one of the simplest and most widely used algorithms
in supervised learning. In linear regression, the algorithm tries to find a linear
relationship between the input features and the output value. The output value is
predicted based on the weighted sum of the input features.
• Logistic Regression
Logistic regression is a type of classification algorithm that is used to predict a
binary output variable. It is commonly used in machine learning applications
where the output variable is either true or false, such as in fraud detection or spam
filtering. In logistic regression, the algorithm tries to find a linear relationship
between the input features and the output variable. The output variable is then
transformed using a logistic function to produce a probability value between 0 and
1.
Algorithms Used in SL Contd..
• Decision Trees
A decision tree is a type of algorithm that is used for both classification and regression
tasks. It is a tree-like structure that is used to model decisions and their possible
consequences. Each internal node in the tree represents a decision, while each leaf node
represents a possible outcome. Decision trees can be used to model complex relationships
between input features and output variables.
• Random Forests
Random forests are an ensemble learning technique that is used for both classification and
regression tasks. They are made up of multiple decision trees that work together to make
predictions. Each tree in the forest is trained on a different subset of the input features and
data. The final prediction is made by aggregating the predictions of all the trees in the
forest
• (SVM)
• Random Forest
Semi-Supervised Learning Model
Problems where you have a large amount of input data and only some of the data is
labeled, are called semi-supervised learning problems. These problems sit in
between both supervised and unsupervised learning. For example, a photo archive
where only some of the images are labeled, (e.g. dog, cat, and person) and the
majority are unlabeled.
Power of both labeled and unlabeled data. Here are some real-world examples:
1. Image classification with limited labeled data:
Imagine training a model to classify different types of animals in images. Labeling a vast amount of images can be expensive and
time-consuming. Semi-supervised learning can come to the rescue. By using a smaller set of labeled images (e.g., images with
clear labels like "cat" or "dog") and a much larger set of unlabeled images, the model can learn from both sources. The labeled
data provides the essential foundation, while the unlabeled data helps refine and improve the model's ability to distinguish between
different animal categories.
Semi-supervised learning Contd..
2. Sentiment analysis on social media: Analyzing public opinion on social
media platforms is valuable for businesses and researchers. However,
manually labeling every single post can be overwhelming. Semi-supervised
learning can be used here. A smaller set of labeled posts expressing clear
positive or negative sentiment can be used to train the model. The model can
then leverage the vast amount of unlabeled data (e.g., unlabeled tweets or
posts) to learn the nuances of language and improve its accuracy in
identifying the sentiment of new, unseen posts.
Semi-supervised learning Contd..
3. Spam filtering in email: Training a spam filter solely on labeled emails (spam
and non-spam) can be limiting. Semi-supervised learning can address this. By using
a smaller set of labeled emails and a much larger set of unlabeled emails
(potentially containing a mix of spam and non-spam), the model can learn the
characteristics of spam emails even in the absence of explicit labels. This helps the
filter adapt and improve its effectiveness over time, especially when dealing with
new and evolving spam tactics.
4. Anomaly detection in industrial processes: Monitoring sensors in industrial
settings can generate a large amount of data. Labeling every single data point as
normal or abnormal is impractical. Semi-supervised learning can be employed here.
Using a smaller set of labeled data points representing normal and abnormal sensor
readings, the model can learn the typical patterns associated with healthy equipment
operation. This allows it to analyze the vast amount of unlabeled sensor data and
identify potential anomalies or equipment failures in real-time, preventing costly
downtime and ensuring operational safety.
Algorithms and Techniques used in semi-
supervised learning
• Self-training (Self-labeling): This is a simple yet effective method where a model
is initially trained with a small amount of labeled data. Then, the model is used to
predict labels for the unlabeled data. Some of these predictions (usually those with
high confidence) are added to the training set as if they were true labels, and the
model is retrained. This process can be repeated iteratively.
• Co-training: In this approach, two models are trained separately on the same
labeled data but with different views (sets of features). Each model then labels
unlabeled data for the other model to use in further training. This method assumes
that the two views are conditionally independent given the class label and that
each view is sufficient for classification.
Algorithms in Semi-SL contd..
• Semi-supervised Support Vector Machines (S3VMs): Traditional SVMs are
extended for semi-supervised learning by finding a decision boundary that not
only separates the labeled data points but also correctly classifies the unlabeled
points. One common approach is to treat the labels of the unlabeled data as
variables and iteratively adjust them along with the decision boundary.
• Graph-based methods: These methods construct a graph where nodes represent
both labeled and unlabeled data points, and edges represent the similarity
between points. The goal is to propagate labels from the labeled points to the
unlabeled points through the graph, based on similarity. Label propagation and
label spreading are examples of graph-based semi-supervised learning algorithms.
Algorithms in Semi-SL Contd..
Deep learning approaches: Recently, semi-supervised learning has been applied to
deep learning through methods like pseudo-labeling (similar to self-training) and
consistency regularization. Consistency regularization encourages the model to
produce the same output for an unlabeled example even after it has been perturbed
in some way (e.g., adding noise). Variational Autoencoders (VAEs) and
Generative Adversarial Networks (GANs) have also been adapted for semi-
supervised learning, leveraging their ability to learn complex data distributions.
Unsupervised Learning Model
Gender Age
M 48
M 67
F 53
M 49
F 34
M 21
Some Commonly used Unsupervised
Learning Algorithms
1. Clustering: This group of algorithms aims to group similar data points together
based on their characteristics.
Popular Examples include:
• K-means clustering: Partitions data into a predefined number of clusters (k).
• Hierarchical clustering: Builds a hierarchy of clusters, allowing for a flexible
number of clusters.
Unsupervised Learning Algorithms contd..
2. Dimensionality reduction: These algorithms aim to reduce the number of
features in a dataset while retaining the most important information. Examples
include:
• Principal Component Analysis (PCA): Identifies the most significant features that
explain most of the data's variance.
3. Anomaly detection: These algorithms identify data points that deviate
significantly from the expected patterns, potentially indicating anomalies or outliers.
Examples include:
• Local Outlier Factor (LOF): Identifies data points that have a significantly lower
density of neighbors compared to surrounding points.
Unsupervised learning algorithms contd..
4. Association rule learning: This method discovers relationships between items or
events in a dataset. An example includes:
• Apriori algorithm: Identifies frequent itemsets and generates association rules
based on their co-occurrence.
5. Latent variable models: These models aim to uncover hidden variables that
explain the observed data. Examples include:
• Autoencoders: Learn compressed representations of the data by encoding the data
into a lower-dimensional space and then reconstructing it from that space.
Unsupervised Learning Model Common Use
Cases
Some common use cases are:
• Clustering: You ask the computer to separate similar data into clusters, this is essential in
research and science.
• Density estimation: The task is to find the distribution of inputs in some space.
• High-Dimension Visualization: Use the computer to help us visualize high-dimension data.
• Generative Models: After a model captures the probability distribution of your input data, it
will be able to generate more data. This can be very useful to make your classifier more
robust.
Some Real-time Examples for Unsupervised
Learning
1. Anomaly detection in network traffic: Unsupervised algorithms can analyze network traffic
data in real-time, identifying unusual patterns that deviate from normal user behavior. This can
help detect potential cyberattacks or other malicious activities as they occur.
3. Content filtering and moderation: Social media platforms and other online services can utilize
unsupervised learning to analyze real-time user-generated content, identifying and filtering out
potentially harmful or inappropriate content before it's published.
Algorithms are trained using labeled Algorithms are used against data that is
Input Data
data. not labeled
Training data Use training data to infer model. No training data is used.
It is not possible to learn larger and It is possible to learn larger and more
Reinforcement Learning
Reinforcement learning (RL) is a type of machine learning technique where an
agent learns to make decisions by interacting with an environment in order to
achieve a specific goal. The agent learns through trial and error, receiving
feedback in the form of rewards or punishments for its actions. The goal of the
agent is to maximize the total cumulative reward it receives over time. (such as
driving a vehicle or playing a game against an opponent).
RL Contd..
ØReinforcement learning uses algorithms that learn from outcomes and decide
which action to take next. After each action, the algorithm receives feedback that
helps it determine whether the choice it made was correct, neutral or incorrect. It
is a good technique to use for automated systems that have to make a lot of small
decisions without human guidance.
ØReinforcement learning is an autonomous, self-teaching system that essentially
learns by trial and error. It performs actions with the aim of maximizing rewards,
or in other words, it is learning by doing in order to achieve the best outcomes.
Main points in Reinforcement learning
• Input: The input should be an initial state from which the model will start
• Output: There are many possible outputs as there are a variety of solutions to a
particular problem.
• Training: The training is based upon the input, The model will return a state and
the user will decide to reward or punish the model based on its output.
• The model keeps continues to learn.
• The best solution is decided based on the maximum reward.
How Reinforcement Learning Works?
• Agent: The entity that learns to make decisions based on its interactions with the
environment.
• Environment: The external system with which the agent interacts. It provides feedback
to the agent based on its actions.
• State: The current situation or configuration of the environment.
• Action: The decision or choice made by the agent in a given state.
• Reward: Feedback from the environment to the agent indicating the desirability of the
action taken in a particular state.
How does reinforcement learning works?
Example: Teaching a Robot to Navigate a Maze
Imagine you have a robot placed in a maze, and your goal is to teach the robot to
find its way out of the maze using reinforcement learning.
• Agent: The robot.
• Environment: The maze.
• State: The robot's current position in the maze.
• Action: Moving in one of the available directions (up, down, left, right).
• Reward: +1 for reaching the exit, -1 for hitting a wall, 0 otherwise.
RL -Process
• Initialization: The robot starts in a random position
within the maze.
• Action Selection: The robot selects an action (e.g., move
up).
• Environment Interaction: The robot moves according to
the chosen action, and its position in the maze changes.
• Reward Assignment: The robot receives a reward based
on its new position in the maze.
• Learning: The robot updates its policy (strategy for
selecting actions) based on the received reward and its
past experiences.
• Repeat: Steps 2-5 are repeated until the robot
consistently finds the exit.
Types of Reinforcement
There are two types of Reinforcement:
• Positive: Positive Reinforcement is defined as when an event, occurs due to a
particular behavior, increases the strength and the frequency of the behavior. In
other words, it has a positive effect on behavior.
• Advantages of reinforcement learning are:
• Maximizes Performance
• Sustain Change for a long period of time
• Too much Reinforcement can lead to an overload of states which can diminish the results
• Negative: Negative Reinforcement is defined as strengthening of behavior
because a negative condition is stopped or avoided.
Advantages of reinforcement learning:
• Increases Behavior
• Provide defiance to a minimum standard of performance
• It Only provides enough to meet up the minimum behavior
Various Practical Applications of Reinforcement
Learning
• RL can be used in robotics for industrial
automation.
• RL can be used in machine learning and
data processing
• RL can be used to create training
systems that provide custom instruction
and materials according to the
requirement of students.
Application of Reinforcement Learnings
In Reinforcement learning decision is dependent, So we give In supervised learning the decisions are independent of each
labels to sequences of dependent decisions other so labels are given to each decision.
• The primary challenge of machine learning is the lack of data or the diversity in
the dataset.
• A machine cannot learn if there is no data available. Besides, a dataset with a
lack of diversity gives the machine a hard time.
• A machine needs to have heterogeneity to learn meaningful insight.
• It is rare that an algorithm can extract information when there are no or few
variations.
• It is recommended to have at least 20 observations per group to help the machine
learn. This constraint leads to poor evaluation and prediction.
Summary of Chapter-1
Our dive into machine learning has begun! We explored core concepts like
supervised, unsupervised, Semi supervised, reinforcement and Deep learning,
showcasing how algorithms learn from data and power advancements in various
fields. This chapter laid the foundation, paving the way for deeper exploration of
specific techniques and real-world applications in upcoming chapters. Remember,
machine learning isn't just about algorithms, but about harnessing data for insights,
informed decisions, and responsible innovation. As we journey on, stay curious,
stay critical, and prepare to unlock the vast potential of machine learning for
solving real-world problems and shaping the future!
THANK YOU!