Introducti0n (MLT)
Introducti0n (MLT)
Introducti0n (MLT)
(Machine learning
techniques)
What is Learning?
Learning can be defined as a relatively permanent change in behaviour or potential
behaviour as a result of direct or indirect experience. Learning is thus a change in
behaviour as a result of experience.
Learning is the process of having one’s behaviour modified, more or less permanently,
by what he does and the consequences of his action, or by what he observes.
Meaning of Learning
There are two primary elements in meaning of learning:
1. Change must be relatively permanent: This means that after “learning”
our behavior must be different, either better or worse as compared to our
behaviour prior to this learning experience.
For example, you “learn” to drive a car or have learned how to use a
computer.
2. This change must occur due to some kind of experience or practice. This
learning is not caused by biological maturation.
Nature of Learning
Learning is a relatively permanent change in knowledge or behavior that results from
practice or experience. There are several key points in this definition.
Elements of Learning
Elements of learning are:
1. Motivation
2. Cues
3. Response
4. Reinforcement
The important components of learning are :
In supervised leaning, the machine is trained on a set of labeled data, which means
that the input data is paired with the desired output. The machine then learns to
predict the output for new input data. Supervised learning is often used for tasks
such as classification, regression, and object detection.
Example:
Let’s say you have a fruit basket that you want to identify. The machine would first
analyze the image to extract features such as its shape, color, and texture. Then, it
would compare these features to the features of the fruits it has already learned
about. If the new image’s features are most similar to those of an apple, the machine
would predict that the fruit is an apple.
For instance, suppose you are given a basket filled with different kinds of fruits.
Now the first step is to train the machine with all the different fruits one by one like
this:
If the shape of the object is rounded and has a depression at the top, is red
in color, then it will be labeled as –Apple.
If the shape of the object is a long curving cylinder having Green-Yellow
color, then it will be labeled as –Banana.
Now suppose after training the data, you have given a new separate fruit, say Banana
from the basket, and asked to identify it.
Since the machine has already learned the things from previous data and this time
has to use it wisely. It will first classify the fruit with its shape and color and would
confirm the fruit name as BANANA and put it in the Banana category. Thus the
machine learns the things from training data
(basket containing fruits) and then applies the knowledge to test data (new fruit).
Thus the machine has no idea about the features of dogs and cats so we can’t
categorize it as ‘dogs and cats ‘. But it can categorize them according to their
similarities, patterns, and differences, i.e., we can easily categorize the above picture
into two parts. The first may contain all pics having dogs in them and the second
part may contain all pics having cats in them. Here you didn’t learn anything before,
which means no training data or examples.
It allows the model to work on its own to discover patterns and information that was
previously undetected. It mainly deals with unlabelled data.
Types of Unsupervised Learning
Unsupervised learning is classified into two categories of algorithms:
Clustering: A clustering problem is where you want to discover the
inherent groupings in the data, such as grouping customers by purchasing
behavior.
Association: An association rule learning problem is where you want to
discover rules that describe large portions of your data, such as people that
buy X also tend to buy Y.
Clustering
Clustering is a type of unsupervised learning that is used to group similar data points
together. Clustering algorithms work by iteratively moving data points closer to their
cluster centers and further away from data points in other clusters.
1. Exclusive (partitioning)
2. Agglomerative
3. Overlapping
4. Probabilistic
Clustering Types:-
1. Hierarchical clustering
2. K-means clustering
3. Principal Component Analysis
4. Singular Value Decomposition
5. Independent Component Analysis
6. Gaussian Mixture Models (GMMs)
7. Density-Based Spatial Clustering of Applications with Noise (DBSCAN)
Application of Unsupervised learning
Non-supervised learning can be used to solve a wide variety of problems, including:
Anomaly detection: Unsupervised learning can identify unusual patterns
or deviations from normal behavior in data, enabling the detection of
fraud, intrusion, or system failures.
Scientific discovery: Unsupervised learning can uncover hidden
relationships and patterns in scientific data, leading to new hypotheses and
insights in various scientific fields.
Recommendation systems: Unsupervised learning can identify patterns
and similarities in user behavior and preferences to recommend products,
movies, or music that align with their interests.
Customer segmentation: Unsupervised learning can identify groups of
customers with similar characteristics, allowing businesses to target
marketing campaigns and improve customer service more effectively.
Image analysis: Unsupervised learning can group images based on their
content, facilitating tasks such as image classification, object detection,
and image retrieval.
Advantages of Unsupervised learning
It does not require training data to be labeled.
Dimensionality reduction can be easily accomplished using unsupervised
learning.
Capable of finding previously unknown patterns in data.
Unsupervised learning can help you gain insights from unlabeled data that
you might not have been able to get otherwise.
Unsupervised learning is good at finding patterns and relationships in data
without being told what to look for. This can help you learn new things
about your data.
Disadvantages of Unsupervised learning
Difficult to measure accuracy or effectiveness due to lack of predefined
answers during training.
The results often have lesser accuracy.
The user needs to spend time interpreting and label the classes which
follow that classification.
Unsupervised learning can be sensitive to data quality, including missing
values, outliers, and noisy data.
Without labeled data, it can be difficult to evaluate the performance of
unsupervised learning models, making it challenging to assess their
effectiveness.
Supervised vs. Unsupervised Machine Learning
Supervised machine Unsupervised machine
Parameters learning learning
Computational
Simpler method Computationally complex
Complexity
Model We can test our model. We can not test our model.
Unsupervised learning
supervised learning needs
does not need any
supervision to train the
supervision to train the
model.
Supervision model.
Reinforcement learning
Reinforcement learning is an area of Machine Learning. It is about taking suitable
action to maximize reward in a particular situation. It is employed by various
software and machines to find the best possible behavior or path it should take in a
specific situation. Reinforcement learning differs from supervised learning in a way
that in supervised learning the training data has the answer key with it so the model
is trained with the correct answer itself whereas in reinforcement learning, there is
no answer but the reinforcement agent decides what to do to perform the given task.
In the absence of a training dataset, it is bound to learn from its experience.
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.
Types of Reinforcement:
There are two types of Reinforcement:
1. Positive: Positive Reinforcement is defined as when an event, occurs due
to a particular behaviour, increases the strength and the frequency of the
behaviour. In other words, it has a positive effect on behaviour.
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
2. Negative: Negative Reinforcement is defined as strengthening of behaviour
because a negative condition is stopped or avoided.
Advantages of reinforcement learning:
Increases Behaviour
Provide defiance to a minimum standard of performance
It Only provides enough to meet up the minimum behaviour
Elements of Reinforcement Learning
1. Image Recognition:
Image recognition is one of the most common applications of machine learning. It is
used to identify objects, persons, places, digital images, etc. The popular use case of
image recognition and face detection is, Automatic friend tagging suggestion
2. Speech Recognition
While using Google, we get an option of "Search by voice," it comes under speech
recognition, and it's a popular application of machine learning.
3. Traffic prediction:
If we want to visit a new place, we take help of Google Maps, which shows us the
correct path with the shortest route and predicts the traffic conditions.
o Real Time location of the vehicle form Google Map app and sensors
o Average time has taken on past days at the same time.
Everyone who is using Google Map is helping this app to make it better. It takes
information from the user and sends back to its database to improve the
performance.
4. Product recommendations:
Machine learning is widely used by various e-commerce and entertainment companies such
as Amazon, Netflix, etc., for product recommendation to the user. Whenever we search for
some product on Amazon, then we started getting an advertisement for the same product
while internet surfing on the same browser and this is because of machine learning.
Google understands the user interest using various machine learning algorithms and
suggests the product as per customer interest.
5. Self-driving cars:
One of the most exciting applications of machine learning is self-driving cars.
Machine learning plays a significant role in self-driving cars. Tesla, the most popular
car manufacturing company is working on self-driving car. It is using unsupervised
learning method to train the car models to detect people and objects while driving.
o Content Filter
o Header filter
o General blacklists filter
o Rules-based filters
o Permission filters
Clustering
Clustering or cluster analysis is a machine learning technique, which
groups the unlabelled dataset. It can be defined as "A way of grouping
the data points into different clusters, consisting of similar data
points. The objects with the possible similarities remain in a group
that has less or no similarities with another group."
It does it by finding some similar patterns in the unlabelled dataset such
as shape, size, color, behaviour, etc., and divides them as per the
presence and absence of those similar patterns.
Decision Tree
A decision tree is a flowchart-like structure used to make decisions or predictions. It
consists of nodes representing decisions or tests on attributes, branches representing
the outcome of these decisions, and leaf nodes representing final outcomes or
predictions. Each internal node corresponds to a test on an attribute, each branch
corresponds to the result of the test, and each leaf node corresponds to a class label
or a continuous value.
The paths from root to leaf represent classification rules
Fig 1.19.1, illustrate the basic flow of decision tree for decision making with labels
(Rain (Yes), Rain (No)).
Pruning
To overcome overfitting, pruning techniques are used. Pruning reduces the size of
the tree by removing nodes that provide little power in classifying instances. There
are two main types of pruning:
Pre-pruning (Early Stopping): Stops the tree from growing once it meets
certain criteria (e.g., maximum depth, minimum number of samples per
leaf).
Post-pruning: Removes branches from a fully grown tree that do not
provide significant power.
Applications of Decision Trees
Business Decision Making: Used in strategic planning and resource
allocation.
Healthcare: Assists in diagnosing diseases and suggesting treatment
plans.
Finance: Helps in credit scoring and risk assessment.
Marketing: Used to segment customers and predict customer behaviour.
Components:
Nodes: Correspond to random variables (continuous or
discrete).
Arcs: Represent causal relationships or conditional probabilities
between nodes.
Directed Acyclic Graph (DAG): The network structure has no
cycles.
Q) Find the probability that ‘P1’ is true (P1 has called ‘gfg’), ‘P2’ is true (P2 has
called ‘gfg’) when the alarm ‘A’ rang, but no burglary ‘B’ and fire ‘F’ has
occurred.
=> P (P1, P2, A, ~B, ~F) [ where- P1, P2 & A are ‘true’ events and ‘~B’ & ‘~F’
are ‘false’ events]
[ Note: The values mentioned below are neither calculated nor computed. They
have observed values]
Burglary ‘B’ –
P (B=T) = 0.001 (‘B’ is true i.e. burglary has occurred)
P (B=F) = 0.999 (‘B’ is false i.e. burglary has not occurred)
Fire ‘F’ –
P (F=T) = 0.002 (‘F’ is true i.e. fire has occurred)
P (F=F) = 0.998 (‘F’ is false i.e. fire has not occurred)
Alarm ‘A’ –
B F P (A=T) P (A=F)
T T 0.95 0.05
T F 0.94 0.06
F T 0.29 0.71
F F 0.001 0.999
The alarm ‘A’ node can be ‘true’ or ‘false’ (i.e. may have rung or may
not have rung). It has two parent nodes burglary ‘B’ and fire ‘F’ which
can be ‘true’ or ‘false’ (i.e. may have occurred or may not have
occurred) depending upon different conditions.
Person ‘P1’ –
A P (P1=T) P (P1=F)
T 0.95 0.05
F 0.05 0.95
The person ‘P1’ node can be ‘true’ or ‘false’ (i.e. may have called the
person ‘gfg’ or not). It has a parent node, the alarm ‘A’, which can be
‘true’ or ‘false’ (i.e. may have rung or may not have rung, upon
burglary ‘B’ or fire ‘F’).
Person ‘P2’ –
A P (P2=T) P (P2=F)
T 0.80 0.20
F 0.01 0.99
The person ‘P2’ node can be ‘true’ or false’ (i.e. may have called the
person ‘gfg’ or not). It has a parent node, the alarm ‘A’, which can be
‘true’ or ‘false’ (i.e. may have rung or may not have rung, upon
burglary ‘B’ or fire ‘F’).
Solution: Considering the observed probabilistic scan –
With respect to the question — P (P1, P2, A, ~B, ~F), we need to get the
probability of ‘P1’. We find it with regard to its parent node – alarm ‘A’. To get
the probability of ‘P2’, we find it with regard to its parent node — alarm ‘A’.
We find the probability of alarm ‘A’ node with regard to ‘~B’ & ‘~F’ since
burglary ‘B’ and fire ‘F’ are parent nodes of alarm ‘A’.
From the observed probabilistic scan, we can deduce –
P (P1, P2, A, ~B, ~F)
= P (P1/A) * P (P2/A) * P (A/~B~F) * P (~B) * P (~F)
= 0.95 * 0.80 * 0.001 * 0.999 * 0.998
= 0.00075
1. Objective of SVM:
o SVM aims to find the optimal hyperplane in an N-
dimensional space that can separate data points into
different classes.
o The hyperplane ensures that the margin between the
closest points of different classes is as maximum as
possible.
Applications of SVM:
i. Text and hypertext classification
ii. Image classification
iii. Recognizing handwritten characters iv. Biological sciences, including protein
classification.
Genetic Algorithm
A genetic algorithm is an adaptive heuristic search algorithm inspired by "Darwin's
theory of evolution in Nature."
Genetic Algorithms are being widely used in different real-world applications, for
example, Designing electronic circuits, code-breaking, image processing, and artificial
creativity.
3. At each step, the genetic algorithm selects individuals at random from the current population to
be parents and uses them to produce the children for the next generation.
Flow chart: The genetic algorithm uses three main types of rules at each step to create the next
generation from the current population:
a. Selection rule: Selection rules select the individuals, called parents, that contribute to the
population at the next generation.
b. Crossover rule: Crossover rules combine two parents to form children for the next generation.
c. Mutation rule: Mutation rules apply random changes to individual parents to form children.
Certainly! Machine Learning (ML) has revolutionized various industries,
but it also comes with its share of challenges. Let’s explore some
common issues faced by ML professionals:
1. Inadequate Training Data:
o Lack of quality and quantity of data can hinder ML
algorithms.
o Noisy or unclean data affects model performance.
o Solutions: Collect more diverse and representative data,
preprocess and clean data effectively.
2. Overfitting and Underfitting:
o Overfitting: Model learns training data too well but performs
poorly on unseen data.
o Underfitting: Model is too simple and fails to capture
underlying patterns.
o Solutions: Use techniques like cross-validation,
regularization, and hyperparameter tuning.
3. Bias and Fairness:
o Models can inherit biases from training data.
o Fairness concerns arise when models discriminate based on
sensitive attributes (e.g., race, gender).
o Solutions: Regularly audit models for bias, use fairness-
aware algorithms, and diverse training data.
4. Interpretability:
o Many ML models (e.g., deep neural networks) are
considered “black boxes.”
o Understanding model decisions is crucial for trust and
accountability.
o Solutions: Explore interpretable models (e.g., decision trees),
feature importance analysis, and visualization.
5. Data Privacy and Security:
o Handling sensitive data requires robust privacy measures.
o Protecting user privacy while extracting useful insights is
challenging.
o Solutions: Anonymize data, use differential privacy, and
comply with privacy regulations.
6. Scalability and Efficiency:
o Training large models can be computationally expensive.
o Real-time applications demand efficient inference.
o Solutions: Optimize algorithms, use distributed computing,
and hardware acceleration.
1. Regression:
o Objective: Predict numerical values (continuous output).
o Examples: House price prediction, stock market forecasting.
o Algorithms: Linear regression, k-nearest neighbours (K-NN), random forest, neural
networks.
2. Classification:
o Objective: Categorize data into different classes (discrete output).
o Examples: Disease diagnosis, sentiment analysis, spam detection.
o Algorithms: Logistic regression, random forest, K-NN, gradient boosting, neural
networks1.
3. Clustering:
o Objective: Group similar data points into clusters.
o Examples: Customer segmentation, image segmentation.
o Algorithms: K-means, DBSCAN, hierarchical clustering, Gaussian mixture models1.
4. Time-Series Forecasting:
o Objective: Predict future values based on historical time-series data.
o Examples: Sales demand forecasting, stock price prediction.
o Algorithms: ARIMA, LSTM, exponential smoothing, Prophet1.
5. Anomaly Detection:
o Objective: Identify outliers or unexpected events in the dataset.
o Examples: Credit card fraud detection, network intrusion detection.
o Algorithms: Isolation Forest, Local Outlier Factor, One-class SVM1.
6. Ranking:
o Objective: Order results based on specific criteria.
o Examples: Search engine result ranking, recommendation systems.
Difference Between Data Science
and Machine Learning
Regression
and Bayesian
Learning