Module 4 & 5
Module 4 & 5
Module 1
• 2006: In the year 2006, computer scientist Geoffrey Hinton has given a new name to neural network
research as "deep learning," and nowadays, it has become one of the most trending technologies.
• 2012: In 2012, Google created a deep neural network which learned to recognize the image of
humans and cats in YouTube videos.
• 2014: In 2014, the Chatbot "Eugen Goostman" cleared the Turing Test. It was the first Chabot who
convinced the 33% of human judges that it was not a machine.
• 2014: DeepFace was a deep neural network created by Facebook, and they claimed that it could
recognize a person with the same precision as a human can do.
• 2016: AlphaGo beat the world's number second player Lee sedol at Go game. In 2017 it beat the
number one player of this game Ke Jie.
• 2017: In 2017, the Alphabet's Jigsaw team built an intelligent system that was able to learn
the online trolling. It used to read millions of comments of different websites to learn to stop online
trolling.
Machine Learning at present:
Now machine learning has got a great advancement in its research, and it is present everywhere around
us, such as self-driving cars, Amazon Alexa, Chatbots, and many more. It
includes Supervised, unsupervised, and reinforcement learning with
clustering, classification, decision tree, SVM algorithms, etc.
Modern machine learning models can be used for making various predictions, including; weather
prediction, disease prediction, stock market analysis, etc.
Machine Learning is said as a subset of artificial intelligence that is mainly concerned with the development
of algorithms which allow a computer to learn from the data and past experiences on their own. The term
machine learning was first introduced by Arthur Samuel in 1959. We can define it in a summarized way as:
A machine has the ability to learn if it can improve its performance by gaining more data.
The importance of machine learning can be easily understood by its uses cases, Currently, machine learning
is used in self-driving cars, cyber fraud detection, face recognition, and friend suggestion by
Facebook, etc. Various top companies such as Netflix and Amazon have build machine learning models that
are using a vast amount of data to analyze the user interest and recommend product accordingly.
Following are some key points which show the importance of Machine Learning:
• Rapid increment in the production of data
• Solving complex problems, which are difficult for a human
• Decision making in various sector including finance
• Finding hidden patterns and extracting useful information from data.
Classification of Machine Learning
At a broader level, machine learning can be classified into three types:
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning
• Supervised learning is a type of machine learning method in which we provide sample of labeled data
to the machine learning system in order to train it, and on that basis, it predicts the output.
• The system creates a model using labeled data to understand the datasets and learn about each
data, once the training and processing are done then we test the model by providing a sample data to
• The goal of supervised learning is to map input data with the output data.
• The supervised learning is based on supervision, and it is the same as when a student learns things in
the supervision of the teacher. The example of supervised learning is spam filtering.
• Supervised machine learning requires the data scientist to train the algorithm with both labeled
• Ensembling: Combining the predictions of multiple machine learning models to produce an accurate
prediction.
Some of the popular supervised learning algorithms are:
1. Linear Regression: It is a simple algorithm used for regression tasks. It models the relationship between the input
features and the target variable using a linear function.
2. Logistic Regression: This algorithm is used for binary classification problems. It models the probability of an input
belonging to a certain class using a logistic function.
3. Decision Trees: Decision trees are versatile algorithms that can be used for both classification and regression tasks. They
create a flowchart-like structure to make decisions based on the input features.
4. Random Forest: Random Forest is an ensemble learning method that combines multiple decision trees to make
predictions. It is robust and can handle high-dimensional data with complex relationships.
5. Support Vector Machines (SVM): SVM is a powerful algorithm for both classification and regression tasks. It finds an
optimal hyperplane that separates different classes in the input space.
6. k-Nearest Neighbors (k-NN): k-NN is a non-parametric algorithm that makes predictions based on the k closest training
examples in the feature space. It can be used for both classification and regression.
7. Neural Networks: Neural networks are a versatile class of algorithms inspired by the human brain. They consist of
interconnected nodes (neurons) organized in layers and can handle complex patterns and large datasets.
jnjnlSDNF
2) Unsupervised Learning
• Unsupervised learning is a learning method in which a machine learns without any supervision.
• The training is provided to the machine with the set of data that has not been labeled, classified, or
categorized, and the algorithm needs to act on that data without any supervision.
• The goal of unsupervised learning is to restructure the input data into new features or a group of objects
• In unsupervised learning, we don't have a predetermined result. The machine tries to find useful
• Unsupervised machine learning algorithms do not require data to be labeled. They sift through
unlabeled data to look for patterns that can be used to group data points into subsets.
• Most types of deep learning, including neural networks, are unsupervised algorithms.
• Association mining: Identifying sets of items in a data set that frequently occur together.
reward for each right action and gets a penalty for each wrong action.
• The agent learns automatically with these feedbacks and improves its performance. In
reinforcement learning, the agent interacts with the environment and explores it.
• The goal of an agent is to get the most reward points, and hence, it improves its performance.
• The robotic dog, which automatically learns the movement of his arms, is an example of
Reinforcement learning.
Other Examples:
– Credit assignment problem
– Game playing
– Robotics
– Balance a pole on your hand
Some of the common reinforcement learning algorithms:
1.Q-Learning: Q-Learning is a model-free RL algorithm that learns an action-value function called Q-function. It uses a
table or a function approximator to estimate the value of taking a particular action in a given state.
2.Deep Q-Network (DQN): DQN is an extension of Q-Learning that uses deep neural networks to estimate the Q-function.
It can handle high-dimensional state spaces and has been successfully applied to complex tasks in Atari games.
3.Policy Gradient Methods: Policy gradient methods directly learn a parameterized policy that maps states to actions.
They use gradient ascent to update the policy parameters based on the expected cumulative rewards.
4.Proximal Policy Optimization (PPO): PPO is a policy optimization algorithm that iteratively updates a policy by
maximizing a surrogate objective function. It aims to strike a balance between policy updates and avoiding large policy
changes.
5.Deep Deterministic Policy Gradient (DDPG): DDPG is an algorithm that combines deep neural networks with
deterministic policy gradient methods. It is primarily used for continuous action spaces.
Example
What is a Machine Learning Model?
• A mathematical model with parameters that map input to output
• Machine Learning models can be understood as a program that has been trained to find
patterns within new data and make predictions.
• These models are represented as a mathematical function that takes requests in the form
of input data, makes predictions on input data, and then provides an output in response.
Building vs. Applying Model
Building Classification Model • Training Phase
• Adjust model parameters
• Use training data
• Testing Phase
• Apply learned model
• Use new data
Classification Algorithms
CART algorithm
• Decision tree ID3 algorithm
• Naïve bayes
K-Nearest Neighbor(KNN) Algorithm for Machine Learning
• K-Nearest Neighbour is one of the simplest Machine Learning algorithms based on Supervised Learning
technique.
• K-NN algorithm assumes the similarity between the new case/data and available cases and put the new case
into the category that is most similar to the available categories.
• K-NN algorithm stores all the available data and classifies a new data point based on the similarity. This
means when new data appears then it can be easily classified into a well suite category by using K- NN
algorithm.
• K-NN algorithm can be used for Regression as well as for Classification but mostly it is used for the
Classification problems.
• K-NN is a non-parametric algorithm, which means it does not make any assumption on underlying data.
• It is also called a lazy learner algorithm because it does not learn from the training set immediately instead it
stores the dataset and at the time of classification, it performs an action on the dataset.
• KNN algorithm at the training phase just stores the dataset and when it gets new data, then it classifies that
data into a category that is much similar to the new data.
How does K-NN work?
The K-NN working can be explained on the basis of the below
algorithm:
Bayes' Theorem:
• Bayes' theorem is also known as Bayes' Rule or Bayes' law, which is used to determine the probability of a hypothesis
with prior knowledge. It depends on the conditional probability.
The formula for Bayes' theorem is given as:
Where,
P(A|B) is Posterior probability: Probability of hypothesis A on the observed event B.
P(B|A) is Likelihood probability: Probability of the evidence given that the probability of a hypothesis is true.
P(A) is Prior Probability: Probability of hypothesis before observing the evidence.
P(B) is Marginal Probability: Probability of Evidence.
Working of Naïve Bayes' Classifier:
Working of Naïve Bayes' Classifier can be understood with the help of the below example:
Suppose we have a dataset of weather conditions and corresponding target variable "Play". So using this dataset
we need to decide that whether we should play or not on a particular day according to the weather conditions.
So to solve this problem, we need to follow the below steps:
The model is under fitting if it’s too simple that it cannot reflect the complexity of the
training dataset.
We can overcome under fitting by:
• Increasing the complexity of the model
• Training the model for a longer period
of time (more epochs) to reduce error
measure its performance on a held-out test set, consisting of examples it hasn’t seen before.
• If an algorithm works well on the training set but fails to generalize, we say it is overfitting.
• Improving generalization (or preventing overfitting) in neural nets is still somewhat of a dark art.
Generalized Model
Model that performs well during training (on new dataset that have never seen before) is
considered the best model (goal)
Overfitting
Generalization & Overfitting
Errors in Classification
Success: Output = Target
• Error: Output != Target
• Error rate = Error = Misclassification Error
• # errors / # samples = % error
Errors in Classification
Thank You!