Chapter Five
Chapter Five
Intoroduction
Ensemble Learning ML
2
Ensemble Learning ML
3
Bagging
4
How Bagging Works
5
Bagging
6
Bagging ML
model.
7
Boosting
of machine learning models. Unlike bagging, which trains each base model
independently,
boosting trains base models sequentially, with each subsequent model focusing
8
How boosting works
A. Base Model Training:
Boosting starts by training a base model (often a weak learner) on the original dataset.
B. Instance Weighting:
After the first model is trained, the misclassified instances are given higher weights, while the
correctly classified instances are given lower weights. This allows subsequent models to focus more on
the difficult instances.
C. Sequential Training:
The subsequent models are trained sequentially, with each model focusing more on the instances that
were misclassified by the previous models. The weights of the instances are adjusted after each model
is trained.
9
Boosting cont..
D. Combining Predictions:
Finally, the predictions of all the models are combined through a weighted sum or voting
to produce the final prediction.
10
Bagging - Example
11
AdaBoost - Example
12
Unsupervised Learning
➔Unsupervised learning aims to find the underlying structure or the distribution
➔ of data. We want to explore the data to find some intrinsic structures in them.
➔ models itself find the hidden patterns and insights from the given data.
➔ Unsupervised learning is much similar as a human learns to think by their own experiences,
which makes it closer to the real AI.
13
Basic Steps In ML
Clustering: Clustering is a method of grouping the objects into clusters such that objects with most
similarities remains into a group.
Association: An association rule is an unsupervised learning method which is used for finding the
relationships between variables in the large database. It determines the set of items that occurs together
in the dataset.
➔ K-means clustering
15
K-means clustering
16
K-means Algorithm
Working Principle
Assignment: Assign each data point to the cluster whose center is nearest.
Update Centers: Recalculate the cluster centers as the mean, variance, Euclidian
distance of the data points in each cluster.
Repeat: Iterate steps 2 and 3 until convergence (when cluster assignments stabilize).
17
Common Terms
Given k, the k-means algorithm is implemented in 5 steps:
https://domino.ai/blog/getting-started-with-k-means-clustering-in-python
18
Python Implementation
EX: Problem Statement:
A retail store wants to get insights about its customers. And then build a system
that can cluster customers into different groups.
19
Introduction to Deep Learning
Deep Learning
20
What is Deep Learning
Deep learning models are inspired by the structure and function of the
human brain, specifically neural networks, and they are designed to
automatically learn features and patterns from large amounts of data.
The output from each preceding layer is taken as input by each one of the
successive layers
21
Deep Learning Cont..
22
Deep Learning Implementation
23
Artificial Neural Network
24
Artificial Neural Network
25
Input Layer
This layer consists of neurons that directly accept the input features of
the data.
It does not perform any transformations or computations. Instead, it acts as
a channel to pass the raw data into the network.
The primary role of the input layer is to serve as the entry point for the
input data into the neural network.
For example, if the input is an image of 28x28 pixels, the input layer will
have 784 neurons (one for each pixel).
26
Hidden Layer
Hidden layers are where the actual computation and learning take
place.
These layers consist of neurons that apply weights and biases to the input,
There can be one or multiple hidden layers, and each layer transforms
27
Output - Layer
The output layer is the final layer of the neural network that produces the
output prediction
regression tasks.
28 In regression tasks, it may use a linear activation function
Perceptron's
classification tasks.
29
Perceptron's parts
input feature.
weight. Weights are parameters that the perceptron learns during training.
30 prediction
Perceptron's parts
C. Bias (b):
The bias term is added to the weighted sum of inputs. It allows the activation
function to be shifted left or right, enabling the perceptron to make more flexible
decisions.
precise output
Activation Function: The weighted sum of the inputs plus the bias is passed through
an activation function. The activation function determines the output of the perceptron
function), which outputs 1 if the weighted sum is greater than a certain threshold and 0
otherwise.
data.
32
Perceptron's parts
33
Types of Activation function
34
Types of Activation function
35
Types of Activation function
36
Types of Activation function
37
When to use which Activation function
Sigmoid: Use for binary classification tasks where the output needs to be interpreted as a
probability between 0 and 1.
Hyperbolic Tangent (Tanh): Use in hidden layers of neural networks for zero-centered
activations and when outputs need to be in the range (-1, 1).
Rectified Linear Unit (ReLU): Use in hidden layers of deep neural networks for faster
convergence and to overcome the vanishing gradient problem.
Leaky ReLU: Use to address the "dying ReLU" problem in deep neural networks where some
neurons become inactive during training.
Softmax: Use in the output layer of neural networks for multi-class classification tasks where
outputs need to be interpreted as probabilities and the sum of probabilities equals 1.
38
When to use which Activation function
39
Perceptron's Summary
40
Simple implementation
41
Thank you Had a Great Time
42