AI Chapter 5
AI Chapter 5
1
Introduction to machine learning
2
Introduction to machine learning (cont’d)
A machine learning algorithm infers patterns and relationships
between different variables(attributes) values in a dataset then uses
that knowledge to generalize beyond the training dataset.
In General, machine learning is a technology which enables computers
to learn automatically from past data by using various algorithms
for building mathematical models and making predictions.
Currently, it is being used for various tasks such as image
recognition, speech recognition, email filtering, Facebook auto-
tagging, recommender system, and many more.
3
The need of Machine Learning
The reason behind the need for machine learning is that it is
capable of doing tasks that are too complex for a person to
implement directly.
As a human, we have some limitations as we cannot access
and get pattern from huge amount of data manually
so for this reason we need some computer systems and here comes the
machine learning to make things easy for us.
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.
In general, the following are some key points which show the importance of
Machine Learning:
Rapid increment in the production of data
Unsupervised learning
Reinforcement learning
6
Supervised Learning Algorithms
Supervised learning is a type of machine learning method in which
we provide sample labeled data (tagged with the correct answer) to
the machine learning algorithms in order to train it.
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/new data to check whether it is predicting the
exact output or not.
Supervised learning can be grouped further in two categories:
Classification
Regression
7
Supervised Learning - Classification
Classification is a process of finding a function which helps in dividing
the dataset into classes based on different parameters/attributes value.
In Classification, a computer program is trained on the training dataset
and based on that training, it categorizes the data into different classes.
The goal here is to predict discrete values belonging to a particular
class and evaluate on the basis of accuracy.
It can be binary classification, model predicts two values either 0 or
1 ; yes or no or multi class classification, model predicts to more than
two class, for example classifying an input/record/test data as low or
medium or high value.
8
Supervised Learning- Regression
Regression is a process of finding the correlations between dependent
and independent variables.
9
Supervised Learning Algorithms
An example of classification and regression on two different
datasets is shown below:
10
Supervised Learning Algorithms
K-Nearest Neighbor(KNN)
Naive Bayes
Decision Trees
Random Forest
11
Unsupervised Learning Algorithms
Unsupervised learning is a learning method in which a machine
learns without any supervision.
Unsupervised learning is a class of machine learning techniques
used to find patterns in data.
The data given to unsupervised algorithms is not labelled, which
means only the input variables (x) are given with no
corresponding output variables.
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.
12
Unsupervised Learning (cont’d)
It groups unsorted information according to similarities, patterns, and
The machine tries to find useful insights from the huge amount of
data.
Association 13
Unsupervised Learning - Clustering
Example:
Using clustering, businesses are able to capture/identify potential
customer segments for selling their products.
Sales companies are able to identify customer segments that are
most likely to use their services.
Companies can evaluate the customer segments and then decide to
sell their product to maximize the profits.
15
Unsupervised Learning - Association
Association: Association rule is used for finding the
relationships between variables in the large database.
It determines the set of items that occurs together in the dataset.
16
Unsupervised Learning Algorithms
K-Means Clustering
17
Reinforcement learning
Reinforcement Learning is a feedback-based machine learning
technique in which an agent learns to behave in an environment by
performing the actions and seeing the results of actions.
For each good action, the agent gets positive feedback, and for
each bad action, the agent gets negative feedback or penalty.
In Reinforcement Learning, the agent learns automatically using
feedbacks without any labeled data, unlike supervised learning.
Since there is no labeled data, so the agent is bound to learn by its
experience only.
18
Reinforcement learning (cont’d)
The primary goal of an agent in reinforcement learning is to
improve the performance by getting the maximum positive rewards.
The agent learns with the process of hit and trial, and based on the
experience, it learns to perform the task in a better way.
Reinforcement learning is a type of machine learning method where
an intelligent agent (computer program) interacts with the
environment and learns to act within that.
Example: Chess game, Google’s Active Query Answering
(AQA) system makes use of reinforcement learning.
19
Applications of Reinforcement learning
Gaming
Robotics
Recommendation systems
20
Terminologies of Machine Learning
Feature: A feature is an individual measurable property of 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.
It is independent variable
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.
It is dependent value.
21
Terminologies of Machine Learning(cont’d)
Training Data: The data used by a machine learning algorithm to
train a model, most of the time use 80% of the dataset.
Test Data: The data used for evaluating the predictive performance of
a model, most of the time use 20% of the dataset
Model: A model is a specific representation learned from data by
applying some machine learning algorithm.
Prediction: Once our model is ready, it can be fed a set of inputs to
which it will provide a predicted output(label).
Accuracy: is how close is a measured value is to the actual(true) value
• Accuracy is how close a measured value is to the
actual (true) 22
Machine Learning Life cycle
Machine learning life cycle involves seven major steps, which are
given below:
1. Gathering Data
2. Data preparation
3. Data Wrangling
4. Analyze Data
5. Train the model
6. Test the model
7. Deployment
1. Gathering Data:
The goal of this step is to identify and obtain all data-related to the
problems.
Data can be collected from various sources such
as files, database, internet etc
2. Data Preparation:
Data preparation is a step where we put our data into a suitable
place and prepare it to use in our machine learning training.
We need to understand the characteristics, format, and quality of
data.
24
Machine Learning Life cycle(cont’d)
3. Data Wrangling:
Data wrangling is the process of cleaning and converting raw
data into a useable format.
It is the process of cleaning the data, selecting the variable to
use, and transforming the data in a proper format to make it more
suitable for analysis.
Cleaning of data is required to address the quality issues.
25
Data Wrangling…
In real-world applications, collected data may have various
issues, including:
Missing Values
Duplicate data
Invalid data
Noise
6. Test Model:
In this step, we check for the accuracy of our model by providing a test
dataset to it.
Testing the model determines the percentage accuracy of the model as
per the requirement of project or problem.
28
Machine Learning Life cycle(cont’d)
7. Deployment:
The last step of machine learning life cycle is deployment, where
we deploy the model in the real-world system.
If the above-prepared model is producing an accurate result as per
our requirement with acceptable speed, then we deploy the model
in the real system.
But before deploying the project, we will check whether it is
improving its performance using available data or not.
The deployment phase is similar to making the final report for a
project.
29
Applications of Machine Learning
30
Deep Learning(DL)
Deep Learning(DL): is a subfield of machine learning(ML) that deals with
algorithms inspired from the biological structure and functioning of a brain
to aid machines with intelligence.
Deep learning uses several layers of nonlinear processing units for feature
extraction and transformation.
Each successive layer uses the output from the previous layer as input.
The word "deep" in "deep learning" refers to the number of layers through
which the data is transformed.
i.e. it evolved from the use of many more hidden layers, making it a “deep” network to
learn more complex patterns.
33
Layers in Deep Learning(cont’d)
As you can see in the preceding figure, the input data is consumed
by the neurons in the first hidden layer produces output, which then
provides this output as an input to the next layer and so on,
eventually resulting in the final output.
Each layer can have one or many neurons, and each of them will
compute a small function (e.g., activation function).
The connection between two neurons of successive layers would
have an associated weight.
34
Layers in Deep Learning(cont’d)
The weight defines the influence of the input to the output for the
next neuron and eventually for the overall final output.
The initial weights would all be random during the model training,
but these weights are updated iteratively to learn to predict a correct
output.
Decomposing the network, we can define few logical building blocks
like input, neuron, layer, weight, output, an activation function inside
the neuron to compute a learning process.
35
Deep Learning Applications
Deep learning is the next big leap after machine learning with a more
advanced implementation.
Currently, it is heading towards becoming an industry standard bringing
a strong promise of being a game changer when dealing with raw
unstructured data.
Deep learning has produced good results for a few applications such as
Image recognition
Self-driving cars
Mobile advertising, Recommendation systems and Financial fraud detection , and so on.
36
Deep Learning Models/Algorithms
The most commonly used deep neural networks or deep learning
models are as follows:
Convolutional neural networks(CNNs)
Back propagation
Activation Functions
37
Convolutional Neural Networks(CNNs)
Convolutional Neural Networks are a type of Deep Learning
Algorithm that take most of the time the image as an input and learn
the various features of the image through filters.
CNNs are powering major advances in machine vision, which has obvious
applications for self-driving cars, robotics, drones.
CNNs used in other tasks such as natural language translation/generation and
sentiment analysis.
CNNs are also being used in drug discovery where they prove to be an efficient
tool for identifying the interaction between the molecules and the biological
proteins for the identification of potential treatments 38
Recurrent Neural Networks(RNNs)
RNN is designed to recognize a data set's sequential attribute and use
Image captioning: detect the images and provide their description in the form of
tags
40
Reading Assignment
Long short-term memory(LSTM)
Back propagation
Activation Functions
2013 41
! ! !
d !
E n
h e
T
42