What’s in it for you?
What is a Random Forest?
Random forest illustration
Applications of Random Forest
How does a random forest work?
Use case: Predicting the quality of wine
Welcome to Raphael's
vineyard in Alsace, France, the
largest wine production region
in the world
What is a Random Forest?
Like Raphael, wine makers
around the world are facing a
grave problem
What is a Random Forest?
So let’s meet with the man
himself and try helping
him out
What is a Random Forest?
What is a Random Forest?
What is a Random Forest?
Hey Raphael. So tell us
how’s it going?
What is a Random Forest?
Not as good as
before…
What is a Random Forest?
Not many people work in this
profession anymore so every
stage of production has got
slower
What is a Random Forest?
If only we could somehow
speed up the process
What is a Random Forest?
Well lucky for you, I’m a
machine learning
engineer
What is a Random Forest?
How about we automate the
quality prediction process for
wine?
What is a Random Forest?
Let me begin by telling you
what machine learning and
random forest is
What is a Random Forest?
Machine learning is the science of applying algorithms that
allow a computer to predict the outcome without being
explicitly programmed
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
• They work for both:
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
• They work for both:
Classification
What is a Random Forest?
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
• They work for both:
Classification
What is a Random Forest?
Categorising objects based on their attributes
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
• They work for both:
Classification
What is a Random Forest?
Categorising objects based on their attributes
Regression
• Random forest is an ensemble machine learning algorithm
• It operates by building multiple decision trees
• They work for both:
Classification
What is a Random Forest?
Categorising objects based on their attributes
Regression
Regression problems have continuous or numerical
valued output variables
Could you explain random
forest in layman terms?
How does a Random Forest work?
Sure! Let’s consider the case of
Sam, a high school student
How does a Random Forest work?
Sam is confused on which
course to take up
Random forest illustration
He decides to ask a
couple of his friends for
suggestions
Random forest illustration
Sam approaches Jane
first
Random forest illustration
Jane asks Sam a few
questions based on which
she can suggest
Random forest illustration
Theoretical?
Random forest illustration
Theoretical?
No
Random forest illustration
Theoretical?
Calculative?
Random forest illustration
Theoretical?
Calculative?
Yes
Random forest illustration
Jane forms a decision
tree based on Sam’s
response and gives her
suggestion
Theoretical?
Calculative?
Yes
Mathematics
Random forest illustration
Next, Sam approaches
Bella
Theoretical?
Calculative?
Mathematics
Random forest illustration
Theoretical?
Calculative?
Field of Science?
Mathematics
Random forest illustration
Theoretical?
Calculative?
Yes
Mathematics
Field of Science?
Random forest illustration
Theoretical?
Calculative?
Mathematics
Field of Science?
New in industry?
Random forest illustration
Theoretical?
Calculative?
Yes
Mathematics
Field of Science?
New in industry?
Random forest illustration
Similar to Jane, Bella also
forms a decision tree based
on Sam’s response and gives
her suggestion
Theoretical?
Calculative?
Mathematics Artificial Intelligence
Field of Science?
New in industry?
Random forest illustration
Theoretical?
Calculative?
Mathematics Artificial Intelligence
Sam asks Terry for his
suggestion
Field of Science?
New in industry?
Random forest illustration
Theoretical?
Calculative?
Mathematics Artificial Intelligence
Field of Science?
New in industry?
Scoring?
Random forest illustration
Theoretical?
Calculative?
Mathematics Artificial Intelligence
Scoring?
Yes
Field of Science?
New in industry?
Random forest illustration
Artificial Intelligence
Theoretical?
Calculative?
Mathematics
Scoring?
Theoretical?
Field of Science?
New in industry?
Random forest illustration
No
Artificial Intelligence
Theoretical?
Calculative?
Mathematics
Scoring?
Theoretical?
Field of Science?
New in industry?
Random forest illustration
MathematicsArtificial Intelligence
Theoretical?
Calculative?
Mathematics
Scoring?
Theoretical?
Field of Science?
New in industry?
Random forest illustration
Since 2 out of 3 friends
suggested Maths, Sam decides
to take Maths
Mathematics
Random forest illustration
So, you see, more the number of
decision trees, more accurate will
be the prediction
Applications of Random Forest
Random forests have a
number of real world
applications already
Applications of Random Forest
In banking, it is used to
predict fraudulent customers
Applications of Random Forest
It is used in analysing
symptoms of the patients and
detecting the disease
Applications of Random Forest
In e–commerce the
recommendations are based on
customer activity
Applications of Random Forest
Stock market trends can be
analysed to predict profit or loss
Applications of Random Forest
To help speed up the process of
wine production, we will automate
the prediction of wine quality
How does a random forest work?
Suppose, our random forest builds
3 decision trees
How does a random forest work?
Our first decision tree splits based
on chlorides and alcohol content
Chlorides<0.08
NoYes
Quality = LowAlcohol>6
Quality = High Quality = Medium
Yes No
How does a random forest work?
Our second decision tree splits
based on pH and sulphate content
Sulphates < 0.6
NoYes
Quality = LowpH < 3.5
Quality = High
Yes No
Quality = Medium
How does a random forest work?
Our third decision tree splits based
on sugar content and pH level
Sugar < 2.5
NoYes
Quality = LowpH < 3.5
Quality = High
Yes No
Quality = Medium
How does a random forest work?
Here’s an unknown glass of wine.
Let’s use our random forest to
predict its quality
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
How does a random forest work?
The new wine has 0.04 chloride
content and alcohol content of 5
Chlorides<0.08
NoYes
Quality = LowAlcohol>6
Quality = High Quality = Medium
Yes No
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
How does a random forest work?
Our first tree predicts the wine to
have a medium quality Chlorides<0.08
NoYes
Alcohol>6
Yes No
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
How does a random forest work?
Quality = Low
Quality = MediumQuality = High
This is our second decision tree.
The wine has sulphates content of
0.5 and a pH level of 3.4 Sulphates < 0.6
NoYes
Quality = LowpH < 3.5
Quality = High
Yes No
Quality = Medium
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
How does a random forest work?
The second tree predicts our wine
to be of a high quality Sulphates < 0.6
NoYes
pH < 3.5
Quality = High
Yes No
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
How does a random forest work?
Quality = Low
Quality = Medium
Our wine has a 1.5 sugar content
and as already mentioned, 0.06
chlorides content Sugar < 2.5
NoYes
Quality = Low
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
pH < 3.5
Quality = High
Yes No
Quality = Medium
How does a random forest work?
Our third tree predicts the
unknown wine to be of high quality
Sugar < 2.5
NoYes
Quality = Low
Feature Value
Chloride content 0.04
Alcohol content 5
Sulphate content 0.5
pH level 3.4
Sugar content 1.5
pH < 3.5
Quality = High
Yes No
Quality = Medium
How does a random forest work?
Since 2 out 3 decisions trees
indicates the quality of our wine to
be high, the forest predicts the
same
How does a random forest work?
Sounds promising! So, shall
we begin?
How does a random forest work?
This is our dataset that holds
all attribute values required
to predict the wine’s quality
Use Case: Predicting the quality of wine
This will be done in
RStudio. So let’s
begin
Use Case: Predicting the quality of wine
The error rate is 26.81%.
Therefore, accuracy is 73.19%
(100-26.81)
Use Case: Predicting the quality of wine
So we have automated the
process of predicting the
quality of wine
Use Case: Predicting the quality of wine
That’s great! Thank you!
Use Case: Predicting the quality of wine
What is a random forest? How does a random forest work?
Key Takeaways
Predicting quality of wine using R
Applications of random forest
How does a random forest work? Training a random forest
Random Forest In R | Random Forest Algorithm | Random Forest Tutorial |Machine Learning |Simplilearn

Random Forest In R | Random Forest Algorithm | Random Forest Tutorial |Machine Learning |Simplilearn

  • 2.
    What’s in itfor you? What is a Random Forest? Random forest illustration Applications of Random Forest How does a random forest work? Use case: Predicting the quality of wine
  • 3.
    Welcome to Raphael's vineyardin Alsace, France, the largest wine production region in the world What is a Random Forest?
  • 4.
    Like Raphael, winemakers around the world are facing a grave problem What is a Random Forest?
  • 5.
    So let’s meetwith the man himself and try helping him out What is a Random Forest?
  • 6.
    What is aRandom Forest?
  • 7.
    What is aRandom Forest?
  • 8.
    Hey Raphael. Sotell us how’s it going? What is a Random Forest?
  • 9.
    Not as goodas before… What is a Random Forest?
  • 10.
    Not many peoplework in this profession anymore so every stage of production has got slower What is a Random Forest?
  • 11.
    If only wecould somehow speed up the process What is a Random Forest?
  • 12.
    Well lucky foryou, I’m a machine learning engineer What is a Random Forest?
  • 13.
    How about weautomate the quality prediction process for wine? What is a Random Forest?
  • 14.
    Let me beginby telling you what machine learning and random forest is What is a Random Forest?
  • 15.
    Machine learning isthe science of applying algorithms that allow a computer to predict the outcome without being explicitly programmed What is a Random Forest?
  • 16.
    • Random forestis an ensemble machine learning algorithm What is a Random Forest?
  • 17.
    • Random forestis an ensemble machine learning algorithm What is a Random Forest?
  • 18.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees What is a Random Forest?
  • 19.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees • They work for both: What is a Random Forest?
  • 20.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees • They work for both: Classification What is a Random Forest?
  • 21.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees • They work for both: Classification What is a Random Forest? Categorising objects based on their attributes
  • 22.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees • They work for both: Classification What is a Random Forest? Categorising objects based on their attributes Regression
  • 23.
    • Random forestis an ensemble machine learning algorithm • It operates by building multiple decision trees • They work for both: Classification What is a Random Forest? Categorising objects based on their attributes Regression Regression problems have continuous or numerical valued output variables
  • 24.
    Could you explainrandom forest in layman terms? How does a Random Forest work?
  • 25.
    Sure! Let’s considerthe case of Sam, a high school student How does a Random Forest work?
  • 26.
    Sam is confusedon which course to take up Random forest illustration
  • 27.
    He decides toask a couple of his friends for suggestions Random forest illustration
  • 28.
  • 29.
    Jane asks Sama few questions based on which she can suggest Random forest illustration
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
    Jane forms adecision tree based on Sam’s response and gives her suggestion Theoretical? Calculative? Yes Mathematics Random forest illustration
  • 35.
  • 36.
  • 37.
  • 38.
    Theoretical? Calculative? Mathematics Field of Science? Newin industry? Random forest illustration
  • 39.
  • 40.
    Similar to Jane,Bella also forms a decision tree based on Sam’s response and gives her suggestion Theoretical? Calculative? Mathematics Artificial Intelligence Field of Science? New in industry? Random forest illustration
  • 41.
    Theoretical? Calculative? Mathematics Artificial Intelligence Samasks Terry for his suggestion Field of Science? New in industry? Random forest illustration
  • 42.
    Theoretical? Calculative? Mathematics Artificial Intelligence Fieldof Science? New in industry? Scoring? Random forest illustration
  • 43.
    Theoretical? Calculative? Mathematics Artificial Intelligence Scoring? Yes Fieldof Science? New in industry? Random forest illustration
  • 44.
  • 45.
  • 46.
  • 47.
    Since 2 outof 3 friends suggested Maths, Sam decides to take Maths Mathematics Random forest illustration
  • 48.
    So, you see,more the number of decision trees, more accurate will be the prediction Applications of Random Forest
  • 49.
    Random forests havea number of real world applications already Applications of Random Forest
  • 50.
    In banking, itis used to predict fraudulent customers Applications of Random Forest
  • 51.
    It is usedin analysing symptoms of the patients and detecting the disease Applications of Random Forest
  • 52.
    In e–commerce the recommendationsare based on customer activity Applications of Random Forest
  • 53.
    Stock market trendscan be analysed to predict profit or loss Applications of Random Forest
  • 54.
    To help speedup the process of wine production, we will automate the prediction of wine quality How does a random forest work?
  • 55.
    Suppose, our randomforest builds 3 decision trees How does a random forest work?
  • 56.
    Our first decisiontree splits based on chlorides and alcohol content Chlorides<0.08 NoYes Quality = LowAlcohol>6 Quality = High Quality = Medium Yes No How does a random forest work?
  • 57.
    Our second decisiontree splits based on pH and sulphate content Sulphates < 0.6 NoYes Quality = LowpH < 3.5 Quality = High Yes No Quality = Medium How does a random forest work?
  • 58.
    Our third decisiontree splits based on sugar content and pH level Sugar < 2.5 NoYes Quality = LowpH < 3.5 Quality = High Yes No Quality = Medium How does a random forest work?
  • 59.
    Here’s an unknownglass of wine. Let’s use our random forest to predict its quality Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 How does a random forest work?
  • 60.
    The new winehas 0.04 chloride content and alcohol content of 5 Chlorides<0.08 NoYes Quality = LowAlcohol>6 Quality = High Quality = Medium Yes No Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 How does a random forest work?
  • 61.
    Our first treepredicts the wine to have a medium quality Chlorides<0.08 NoYes Alcohol>6 Yes No Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 How does a random forest work? Quality = Low Quality = MediumQuality = High
  • 62.
    This is oursecond decision tree. The wine has sulphates content of 0.5 and a pH level of 3.4 Sulphates < 0.6 NoYes Quality = LowpH < 3.5 Quality = High Yes No Quality = Medium Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 How does a random forest work?
  • 63.
    The second treepredicts our wine to be of a high quality Sulphates < 0.6 NoYes pH < 3.5 Quality = High Yes No Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 How does a random forest work? Quality = Low Quality = Medium
  • 64.
    Our wine hasa 1.5 sugar content and as already mentioned, 0.06 chlorides content Sugar < 2.5 NoYes Quality = Low Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 pH < 3.5 Quality = High Yes No Quality = Medium How does a random forest work?
  • 65.
    Our third treepredicts the unknown wine to be of high quality Sugar < 2.5 NoYes Quality = Low Feature Value Chloride content 0.04 Alcohol content 5 Sulphate content 0.5 pH level 3.4 Sugar content 1.5 pH < 3.5 Quality = High Yes No Quality = Medium How does a random forest work?
  • 66.
    Since 2 out3 decisions trees indicates the quality of our wine to be high, the forest predicts the same How does a random forest work?
  • 67.
    Sounds promising! So,shall we begin? How does a random forest work?
  • 68.
    This is ourdataset that holds all attribute values required to predict the wine’s quality Use Case: Predicting the quality of wine
  • 69.
    This will bedone in RStudio. So let’s begin Use Case: Predicting the quality of wine
  • 70.
    The error rateis 26.81%. Therefore, accuracy is 73.19% (100-26.81) Use Case: Predicting the quality of wine
  • 71.
    So we haveautomated the process of predicting the quality of wine Use Case: Predicting the quality of wine
  • 72.
    That’s great! Thankyou! Use Case: Predicting the quality of wine
  • 73.
    What is arandom forest? How does a random forest work? Key Takeaways Predicting quality of wine using R Applications of random forest How does a random forest work? Training a random forest

Editor's Notes