Machine Learning
Machine Learning
2
Machine learning
• In Machine learning, the question “Can machines think?” is replaced
with the question “Can machines do what we (as thinking entities)
can do?”
• Machine Learning is a concept which allows the machine to learn
from examples and experience, and that too without being explicitly
programmed.
• So instead of you writing the code, what you do is you feed data to
the generic algorithm, and the algorithm/ machine builds the logic
based on the given data.
3
4
Contd.. Example 1:
• Suppose that you decide to check out that offer for a vacation .
• You browse through the travel agency website and search for a hotel.
• When you look at a specific hotel, just below the hotel description
there is a section titled “You might also like these hotels”.
• This is a common use case of Machine Learning called
“Recommendation Engine”.
• The machine has been trained in this case in order to predict which all
would be the best hotels to show you under that section.
5
Contd.. Example 2
• Have you ever shopped online?
• So while checking for a product, did you notice when it recommends
for a product similar to what you are looking for?
• Did you notice “the person bought this product; also bought this”
• How are they doing this recommendation?
• This is machine learning.
6
Contd.. Example 3
• Did you ever get a call from any bank or finance company asking you
to take a loan or an insurance policy?
• What do you think, do they call everyone?
• No, they call only a few selected customers who they think will
purchase their product.
• How do they select? This is target marketing and can be applied using
Clustering.
• This is machine learning.
7
Machine Learning
• Machine Learning is a subset of artificial intelligence which focuses
mainly on learning from their experience and making predictions
based on its experience.
• What does it do?
• It enables the computers or the machines to make data-driven
decisions rather than being explicitly programmed for carrying out a
certain task.
• These programs or algorithms are designed in a way that they learn
and improve over time when are exposed to new data.
8
How does Machine Learning Work?
• Machine Learning algorithm is trained using a training data set to create a
model.
• When new input data is introduced to the ML algorithm, it makes a
prediction on the basis of the model.
• The prediction is evaluated for accuracy and if the accuracy is acceptable,
the Machine Learning algorithm is deployed.
• If the accuracy is not acceptable, the Machine Learning algorithm is trained
again and again with an augmented training data set.
• Often, machine learning methods are broken into two phases:
• 1. Training: A model is learned from a collection of training data.
• 2. Application: The model is used to make decisions about some new test
data
9
10
Types of Machine Learning
• Machine learning is sub-categorized to three types:
• Supervised Learning – Train Me!
• Unsupervised Learning – I am self sufficient in learning
• Reinforcement Learning – My life My rules! (Hit & Trial)
11
12
13
14
What is Supervised Learning?
• Supervised learning as the name indicates the presence of a supervisor as a
teacher.
• Supervised Learning is the one, where you can consider the learning is
guided by a teacher. The teacher provides good examples for the student
to memorize, and the student then derives general rules from these
specific examples.
• We have a dataset which acts as a teacher and its role is to train the model
or the machine.
• Basically supervised learning is a learning in which we teach or train the
machine using data which is well labeled that means some data is already
tagged with the correct answer.
• Once the model gets trained it can start making a prediction or decision
when new data is given to it.
15
16
• 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 different fruits one
by one like this:
• If shape of object is rounded and depression at top having color Red then it
will be labelled as –Apple.
• If shape of object is long curving cylinder having color Green-Yellow then it
will be labelled as –Banana.
• Now suppose after training the data, you have given a new separate fruit
say Banana from basket and asked to identify it.
• Since the machine has already learned the things from previous data and
this time have 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
Banana category. Thus the machine learns the things from training
data(basket containing fruits) and then apply the knowledge to test
data(new fruit).
• Supervised learning is classified into two categories of algorithms:
• Classification: A classification problem is when the output variable is a
category, such as “Red” or “blue” or “disease” and “no disease”.
• Regression: A regression problem is when the output variable is a real
value, such as “dollars” or “weight”. 17
2. Unsupervised learning
• Unsupervised learning is the training of machine using information
that is neither classified nor labeled and allowing the algorithm to act
on that information without guidance.
• Here the task of machine is to group unsorted information according
to similarities, patterns and differences without any prior training of
data.
• Unlike supervised learning, no teacher is provided that means no
training will be given to the machine.
• Therefore machine is restricted to find the hidden structure in
unlabeled data by our-self.
18
• For instance, suppose it is given an image having both dogs and cats which
have not seen ever.
• Thus the machine has no idea about the features of dogs and cat so can’t
categorize it in dogs and cats.
• But it can categorize them according to their similarities, patterns, and
differences i.e., can easily categorize the above picture into two parts.
• First may contain all pics having dogs in it and second part may contain all
pics having cats in it.
• Here it didn’t learn anything before, means no training data or examples.
• Unsupervised learning 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.
19
20
What is Unsupervised Learning?
• The model learns through observation and finds structures in the
data.
• Once the model is given a dataset, it automatically finds patterns and
relationships in the dataset by creating clusters in it.
• What it cannot do is add labels to the cluster, like it cannot say this a
group of apples or mangoes, but it will separate all the apples from
mangoes.
• Suppose we presented images of apples, bananas and mangoes to
the model, so what it does, based on some patterns and relationships
it creates clusters and divides the dataset into those clusters. Now if a
new data is fed to the model, it adds it to one of the created clusters.
21
22
What is Reinforcement Learning?
• It is the ability of an agent to interact with the environment and find out what is
the best outcome.
• It follows the concept of hit and trial method.
• The agent is rewarded or penalized with a point for a correct or a wrong answer,
and on the basis of the positive reward points gained the model trains itself. And
again once trained it gets ready to predict the new data presented to it.
• When you present the algorithm with examples that lack labels, as in
unsupervised learning. However, you can accompany an example with positive or
negative feedback according to the solution the algorithm proposes comes under
the category of Reinforcement learning, which is connected to applications for
which the algorithm must make decisions (so the product is prescriptive, not just
descriptive, as in unsupervised learning), and the decisions bear consequences. In
the human world, it is just like learning by trial and error.
23
24
25
Machine Learning Use Case
• Machine learning uses include face detection, cortana, Netflix
Recommendation System and many more.
26
27
28
29
Applications of Machine Learning
• Sample applications of machine learning:
• Web search: ranking page based on what you are most likely to click on.
• Computational biology: rational design drugs in the computer based on past experiments.
• Finance: decide who to send what credit card offers to. Evaluation of risk on credit offers. How to
decide where to invest money.
• E-commerce: Predicting customer churn. Whether or not a transaction is fraudulent.
• Space exploration: space probes and radio astronomy.
• Robotics: how to handle uncertainty in new environments. Autonomous. Self-driving car.
• Information extraction: Ask questions over databases across the web.
• Social networks: Data on relationships and preferences. Machine learning to extract value from
data.
• Debugging: Use in computer science problems like debugging. Labor intensive process. Could
suggest where the bug could be.
30
Machine Learning - II
31
• we know humans learn from their past experiences and machines follow
instructions given by humans
• But what if humans can Turn machines to learn from the past data and
to what humans can do act much faster, well that's called machine
learning.
• But it's a lot more than just learning it's also about understanding and
reasoning.
• that's when machine learning comes in.
• It learns the data, builds the prediction model and when the new
data point comes in, it can easily project for it .
• More the data , better the model, higher will be the accuracy.
• There are many ways in which the machine learns.
• It could be either supervised learning, unsupervised learning or
reinforcement learning.
32
33
34
35
• let's first quickly understand supervised learning.
• Suppose your friend gives you 1 million coins of three different currencies
• each coin has different weights; for example a coin of one rupee weighs
three grams ; one euro weighs seven grams and one their own weighs four
grams.
• your model will predict the currency of the coin.
• here your weight becomes the feature of coins while currency becomes the
label.
• when you feed this data to the machine learning model it learns which
feature is associated with which slip.
• for example it will learn that if a coin is of three grams it will be a one
rupee coin.
• your model will predict the currency hence supervised learning uses labels
data to train the model.
• here the Machine knew the features of the object and also the labels
associated with those features.
36
37
38
• let's move to unsupervised learning and see the difference.
• suppose you have cricket data set of various players with their respective
scores and wickets taken.
• when you feed this data set to the machine the machine identifies the
pattern of player performance so it plots this data with the respective
wickets on the x axis while runs on the y axis
• while looking at the data you will clearly see that there are two clusters
the one cluster are the players who scored high runs and took less wickets
• while the other cluster is of the players who scored less runs but took
many wickets
• so here we interpret these two clusters as batsman and bowlers
• the important point to note here is that there were no labels of batsmen
Bowlers
• hence the learning with unlabeled data is unsupervised learning
• so we saw a supervised learning where the data was labeled and the
unsupervised learning where the data was unlabeled
39
40
• Then there's reinforcement learning which is a reward
based learning or we can say that it works on the principle
of feedback
• here let's say you provide the system with an image of a
dog and ask it to identify it
• the system identifies it as a cat
• so you give a negative feedback to the Machine saying
that it's a dog's image
• the machine will learn from the feedback and finally if it
comes across any other image of a dog it will be able to
classify it correctly that is reinforcement learning
41
42
• to generalize machine learning model let's see a flowchart
• Input is given to a machine learning model which then gives the
output according to the algorithm applied if it's right we take the
output as a final result else we provide feedback to the train model
and ask it to predict until it learns.
43
44
45
46