UNIT4
UNIT4
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 can be broadly classified into three categories, as mentioned below, based
on the nature of the learning data and interaction between the learner and the environment.
There are four categories of machine learning algorithms as shown below −
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 it’s a dog or a cat from these labelled 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.
Supervised learning can be further classified into two types:
Regression
Classification.
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
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
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:
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.
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
behaviour 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.
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:
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:
We use these techniques when we are dealing with data that is a little bit labeled and the rest
large portion of it is unlabeled. We can use the unsupervised techniques to predict labels and
then feed these labels to supervised techniques. This technique is mostly applicable in the
case of image data sets where usually all images are not labeled.
Example: Consider that we are building a language translation model, having labeled
translations for every sentence pair can be resources intensive. It allows the models to learn
from labeled and unlabeled sentence pairs, making them more accurate. This technique has
led to significant improvements in the quality of machine translation services.
Advantages of Semi- Supervised Machine Learning
REINFORCEMENT LEARNING
Reinforcement Machine learning algorithm 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 behaviour 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.
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.
There are two main types of reinforcement learning:
Positive reinforcement
Negative reinforcement
POSITIVE REINFORCEMENT
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.
DECISION TREES
A decision tree in machine learning is a versatile, interpretable algorithm used for
predictive modelling. It structures decisions based on input data, making it suitable for both
classification and regression tasks. This article delves into the components, terminologies,
construction, and advantages of decision trees, exploring their applications and learning
algorithms.
A decision tree is a type of supervised learning algorithm that is commonly used in
machine learning to model and predict outcomes based on input data. It is a tree-like
structure where each internal node tests on attribute, each branch corresponds to attribute
value and each leaf node represents the final decision or prediction. The decision tree
algorithm falls under the category of supervised learning. They can be used to solve both
regression and classification problems.
Decision Tree Terminologies
There are specialized terms associated with decision trees that denote various components
and facets of the tree structure and decision-making procedure. :
Root Node: A decision tree’s root node, which represents the original choice or
feature from which the tree branches, is the highest node.
Internal Nodes (Decision Nodes): Nodes in the tree whose choices are determined by
the values of particular attributes. There are branches on these nodes that go to other
nodes.
Leaf Nodes (Terminal Nodes): The branches’ termini, when choices or forecasts are
decided upon. There are no more branches on leaf nodes.
Branches (Edges): Links between nodes that show how decisions are made in
response to particular circumstances.
Splitting: The process of dividing a node into two or more sub-nodes based on a
decision criterion. It involves selecting a feature and a threshold to create subsets of
data.
Parent Node: A node that is split into child nodes. The original node from which a split
originates.
Child Node: Nodes created as a result of a split from a parent node.
Decision Criterion: The rule or condition used to determine how the data should be
split at a decision node. It involves comparing feature values against a threshold.
Pruning: The process of removing branches or nodes from a decision tree to improve
its generalisation and prevent overfitting.
The process of forming a decision tree involves recursively partitioning the data based on the
values of different attributes. The algorithm selects the best attribute to split the data at each
internal node, based on certain criteria such as information gain or Gini impurity. This splitting
process continues until a stopping criterion is met, such as reaching a maximum depth or
having a minimum number of instances in a leaf node.
As you can see from the above image the Decision Tree works on the Sum of Product form
which is also known as Disjunctive Normal Form. In the above image, we are predicting the
use of computer in the daily life of people. In the Decision Tree, the major challenge is the
identification of the attribute for the root node at each level. This process is known as
attribute selection.
We have two popular attribute selection measures:
Information Gain
Gini Index