SlideShare a Scribd company logo
Decision Trees
Machine Learning - Classfication
Decision Trees
In this session we’ll learn about Decision Trees.
Decision Trees are versatile Machine Learning algorithms that can perform
● Classification Tasks
● Regression Tasks
● And even multi-output tasks
They are very powerful algorithms, capable of fitting complex datasets. Also
used in Random Forest (remember our project?)
Machine Learning - Classfication
Decision Trees
Example of a Decision Tree
Machine Learning - Classfication
Decision Trees
● Working with Decision Trees
○ Train
○ Visualize
○ Make prediction with Decision tree
● The CART training algorithm used by Scikit-Learn
● How to regularize trees and use them for regression tasks
● Regression with Decision Trees
● Limitations of Decision Trees
What we’ll learn in this session ?

Recommended for you

Word embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTMWord embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTM

Word Embeddings, Application of Sequence modelling, Recurrent neural network , drawback of recurrent neural networks, gated recurrent unit, long short term memory unit, Attention Mechanism

deep learningsequence modelling
Recurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: TheoryRecurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: Theory

The document provides an overview of recurrent neural networks (RNNs) and their advantages over feedforward neural networks. It describes the basic structure and training of RNNs using backpropagation through time. RNNs can process sequential data of variable lengths, unlike feedforward networks. However, RNNs are difficult to train due to vanishing and exploding gradients. More advanced RNN architectures like LSTMs and GRUs address this by introducing gating mechanisms that allow the network to better control the flow of information.

lstmrnngru
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...

This Edureka Recurrent Neural Networks tutorial will help you in understanding why we need Recurrent Neural Networks (RNN) and what exactly it is. It also explains few issues with training a Recurrent Neural Network and how to overcome those challenges using LSTMs. The last section includes a use-case of LSTM to predict the next word using a sample short story Below are the topics covered in this tutorial: 1. Why Not Feedforward Networks? 2. What Are Recurrent Neural Networks? 3. Training A Recurrent Neural Network 4. Issues With Recurrent Neural Networks - Vanishing And Exploding Gradient 5. Long Short-Term Memory Networks (LSTMs) 6. LSTM Use-Case

rnnrecurrent neural networksrnn lstm
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
Let’s just build a Decision Tree and take a look at how it makes predictions
We’ll train a DecisionTreeClassifier using Scikit Learn on the famous Iris
dataset.
And then we’ll see how it works.
Machine Learning - Classfication
Decision Trees
Iris Dataset - Training and Visualizing a Decision Tree
The iris dataset consists of 4 features namely :
● Petal Length
● Petal Width
● Sepal Length
● Sepal Width
There are three classes namely :
● Iris Setosa
● Iris Versicolor
● Iris Virginica
Machine Learning - Classfication
Decision Trees
Iris Dataset - Training and Visualizing a Decision Tree
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
The iris dataset has 4 features petal length, petal width, sepal length and
sepal width.
But here we’ll only use two features i.e. petal length and petal width.

Recommended for you

Recurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRURecurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRU

Recurrent Neural Networks have shown to be very powerful models as they can propagate context over several time steps. Due to this they can be applied effectively for addressing several problems in Natural Language Processing, such as Language Modelling, Tagging problems, Speech Recognition etc. In this presentation we introduce the basic RNN model and discuss the vanishing gradient problem. We describe LSTM (Long Short Term Memory) and Gated Recurrent Units (GRU). We also discuss Bidirectional RNN with an example. RNN architectures can be considered as deep learning systems where the number of time steps can be considered as the depth of the network. It is also possible to build the RNN with multiple hidden layers, each having recurrent connections from the previous time steps that represent the abstraction both in time and space.

nlpdeep neural networksrnn
Neural Networks: Support Vector machines
Neural Networks: Support Vector machinesNeural Networks: Support Vector machines
Neural Networks: Support Vector machines

This document discusses support vector machines (SVMs) for pattern classification. It begins with an introduction to SVMs, noting that they construct a hyperplane to maximize the margin of separation between positive and negative examples. It then covers finding the optimal hyperplane for linearly separable and nonseparable patterns, including allowing some errors in classification. The document discusses solving the optimization problem using quadratic programming and Lagrange multipliers. It also introduces the kernel trick for applying SVMs to non-linear decision boundaries using a kernel function to map data to a higher-dimensional feature space. Examples are provided of applying SVMs to the XOR problem and computer experiments classifying a double moon dataset.

support vector machinessvmneural networks
CNN Tutorial
CNN TutorialCNN Tutorial
CNN Tutorial

This document provides an overview of convolutional neural networks and summarizes four popular CNN architectures: AlexNet, VGG, GoogLeNet, and ResNet. It explains that CNNs are made up of convolutional and subsampling layers for feature extraction followed by dense layers for classification. It then briefly describes key aspects of each architecture like ReLU activation, inception modules, residual learning blocks, and their performance on image classification tasks.

Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
We will follow the following steps to train and visualize our decision tree
1. Load the Iris dataset using Scikit Learn
2. Select only the Petal length and Petal width features
3. Train our Decision Tree classifier on the Iris Dataset
4. Visualize our Decision Tree using export_graphviz()
5. export_graphviz() gives us a file in .dot format which we will convert to
png using the dot command line tool
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
1. Load the Iris dataset using Scikit Learn
>>> from sklearn.datasets import load_iris
>>> iris = load_iris()
Run it in jupyter notebook
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
2. Select only the Petal length and Petal width features
>>> X = iris.data[:, 2:] # petal length and width
>>> y = iris.target
Run it in jupyter notebook
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
3. Train our Decision Tree classifier on the Iris Dataset
>>> from sklearn.tree import DecisionTreeClassifier
>>> tree_clf = DecisionTreeClassifier(max_depth=2)
>>> tree_clf.fit(X, y)
Run it in jupyter notebook

Recommended for you

Beginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix FactorizationBeginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix Factorization

This is a quick introduction to Non-Negative Matrix Factorization to implement supervised machine learning and the NNMF predictive model.

machine learningrecommendermatrix (mathematics)
Hyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine LearningHyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine Learning

▸ Machine Learning / Deep Learning models require to set the value of many hyperparameters ▸ Common examples: regularization coefficients, dropout rate, or number of neurons per layer in a Neural Network ▸ Instead of relying on some "expert advice", this presentation shows how to automatically find optimal hyperparameters ▸ Exhaustive Search, Monte Carlo Search, Bayesian Optimization, and Evolutionary Algorithms are explained with concrete examples

machine learningoptimization
Ensemble methods
Ensemble methodsEnsemble methods
Ensemble methods

A brief presentation given on the basics of Ensemble Methods. Given as a 'Lightning Talk' during the 7th Cohort of General Assembly's Data Science Immersive Course

Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
4. Visualize our Decision Tree using export_graphviz()
We can visualize the trained decision tree using the export_graphviz()
method.
>>> from sklearn.tree import export_graphviz
>>> export_graphviz( tree_clf,
out_file=image_path("iris_tree.dot"),
feature_names=iris.feature_names[2:],
class_names=iris.target_names, rounded=True,
filled=True )
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
5. Converting to Png file
Then you can convert this .dot file to a variety of formats such as PDF or
PNG using the dot command- line tool from the graphviz package.
This command line converts the .dot file to a .png image file:
>>> dot -Tpng iris_tree.dot -o iris_tree.png
Run it in the console
Machine Learning - Classfication
Decision Trees
Training and Visualizing a Decision Tree
Machine Learning - Classfication
Decision Trees
Understanding the Decision Tree
A node’s value attribute tells
you how many training instances
of each class this node applies to
for example, the bottom-right
node applies to 0 Iris-Setosa, 1
Iris- Versicolor, and 45 Iris-
Virginica.

Recommended for you

Document clustering and classification
Document clustering and classification Document clustering and classification
Document clustering and classification

محاضرة ألقيتها ضمن برنامج السيمينار الذي نفذه قسم علوم الحاسوب وتكنولوجيا المعلومات في الكلية الجامعية للعلوم والتكنولوجيا عام 2012

classificationdata miningdocument clustering
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...

This presentation on Recurrent Neural Network will help you understand what is a neural network, what are the popular neural networks, why we need recurrent neural network, what is a recurrent neural network, how does a RNN work, what is vanishing and exploding gradient problem, what is LSTM and you will also see a use case implementation of LSTM (Long short term memory). Neural networks used in Deep Learning consists of different layers connected to each other and work on the structure and functions of the human brain. It learns from huge volumes of data and used complex algorithms to train a neural net. The recurrent neural network works on the principle of saving the output of a layer and feeding this back to the input in order to predict the output of the layer. Now lets deep dive into this presentation and understand what is RNN and how does it actually work. Below topics are explained in this recurrent neural networks tutorial: 1. What is a neural network? 2. Popular neural networks? 3. Why recurrent neural network? 4. What is a recurrent neural network? 5. How does an RNN work? 6. Vanishing and exploding gradient problem 7. Long short term memory (LSTM) 8. Use case implementation of LSTM Simplilearn’s Deep Learning course will transform you into an expert in deep learning techniques using TensorFlow, the open-source software library designed to conduct machine learning & deep neural network research. With our deep learning course, you'll master deep learning and TensorFlow concepts, learn to implement algorithms, build artificial neural networks and traverse layers of data abstraction to understand the power of data and prepare you for your new role as deep learning scientist. Why Deep Learning? It is one of the most popular software platforms used for deep learning and contains powerful tools to help you build and implement artificial neural networks. Advancements in deep learning are being seen in smartphone applications, creating efficiencies in the power grid, driving advancements in healthcare, improving agricultural yields, and helping us find solutions to climate change. With this Tensorflow course, you’ll build expertise in deep learning models, learn to operate TensorFlow to manage neural networks and interpret the results. And according to payscale.com, the median salary for engineers with deep learning skills tops $120,000 per year. You can gain in-depth knowledge of Deep Learning by taking our Deep Learning certification training course. With Simplilearn’s Deep Learning course, you will prepare for a career as a Deep Learning engineer as you master concepts and techniques including supervised and unsupervised learning, mathematical and heuristic aspects, and hands-on modeling to develop algorithms. Those who complete the course will be able to: Learn more at: https://www.simplilearn.com/

recurrent neural networkrecurrent neural network explainedrecurrent neural network tutorial
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...

Pruning is the process of removing branches or nodes from a decision tree to simplify it and reduce overfitting. Some key points about pruning: - Pruning reduces the complexity of the decision tree to avoid overfitting to the training data. - It is done to improve the accuracy of the model on new unseen data by removing noisy or unstable parts of the tree. - Common pruning techniques include pre-pruning, cost-complexity pruning, reduced error pruning etc. - The goal of pruning is to find a tree with optimal complexity that balances bias and variance for best generalization on new data. To answer your question - tree based models and linear models each have their own advantages in different situations:

decision tree pythondecision treeedureka
Machine Learning - Classfication
Decision Trees
Understanding the Decision Tree
A node’s gini attribute
measures its impurity: a node is
“pure” (gini=0) if all training
instances it applies to belong to
the same class.
For example, since the depth-1
left node applies only to Iris-
Setosa training instances, it is
pure and its gini score is 0.
Machine Learning - Classfication
Decision Trees
Making Predictions
To make a prediction the
decision classifier follows these
steps :
● Start at the root node (depth
0, at the top), this node asks
whether the flower’s petal
length is smaller than or equal
to 2.45 cm:
Machine Learning - Classfication
Decision Trees
Making Predictions
○ If it is, then you move down to
the root’s left child node
(depth 1, left). In this case it is
a leaf node hence the flower is
predicted as setosa.
Machine Learning - Classfication
Decision Trees
Making Predictions
○ If it is not, then you move
down to the root’s right child
node (depth 1, right), since it
is not a leaf node it asks
further questions as, is the
petal width smaller than or
equal to 1.75 cm?

Recommended for you

Random forest algorithm
Random forest algorithmRandom forest algorithm
Random forest algorithm

The document discusses the random forest algorithm. It introduces random forest as a supervised classification algorithm that builds multiple decision trees and merges them to provide a more accurate and stable prediction. It then provides an example pseudocode that randomly selects features to calculate the best split points to build decision trees, repeating the process to create a forest of trees. The document notes key advantages of random forest are that it avoids overfitting and can be used for both classification and regression tasks.

random forestalgorithm
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingBERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

We present BERT model: Pre-training of Deep Bidirectional Transformers for Language Understanding. The model obtained SOTA results on many NLP tasks

bertnlpdeep learning
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...

https://telecombcn-dl.github.io/2017-dlsl/ Winter School on Deep Learning for Speech and Language. UPC BarcelonaTech ETSETB TelecomBCN. The aim of this course is to train students in methods of deep learning for speech and language. Recurrent Neural Networks (RNN) will be presented and analyzed in detail to understand the potential of these state of the art tools for time series processing. Engineering tips and scalability issues will be addressed to solve tasks such as machine translation, speech recognition, speech synthesis or question answering. Hands-on sessions will provide development skills so that attendees can become competent in contemporary data analytics tools.

recurrent neural networksdeep learningspeech recognition
Machine Learning - Classfication
Decision Trees
Making Predictions
● If it is, then your flower is
most likely an Iris- Versicolor
(depth 2, left).
● If it is not, If not, it is likely an
Iris-Virginica (depth 2, right).
Machine Learning - Classfication
Decision Trees
Decision Tree’s decision boundaries.
Boundary made at depth 0.
Petal length <= 2.45
Machine Learning - Classfication
Decision Trees
Decision Tree’s decision boundaries.
Boundary made at depth 1.
Petal width <= 1.75
Machine Learning - Classfication
Decision Trees
Decision Tree’s decision boundaries.
This would have been the decision
boundary to divide the tree further
i.e. if max_depth was set to 3

Recommended for you

Mobilenetv1 v2 slide
Mobilenetv1 v2 slideMobilenetv1 v2 slide
Mobilenetv1 v2 slide

The document summarizes research on developing efficient convolutional neural network architectures called MobileNets that are well-suited for mobile and embedded vision applications. The key ideas are using depthwise separable convolutions to factorize standard convolutions and using a width multiplier and resolution multiplier to control model size. Experiments show MobileNets achieve higher accuracy and speed than prior mobile networks on image classification and object detection tasks while having a smaller memory footprint.

Rnn and lstm
Rnn and lstmRnn and lstm
Rnn and lstm

RNN AND LSTM This document provides an overview of RNNs and LSTMs: 1. RNNs can process sequential data like time series data using internal hidden states. 2. LSTMs are a type of RNN that use memory cells to store information for long periods of time. 3. LSTMs have input, forget, and output gates that control information flow into and out of the memory cell.

rnnlstmneural networks
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...

goog is a great place to work sincerely excellent communication skills self motivated ability to work sincerely excellent communication skills self motivated

marketing
Machine Learning - Classfication
Decision Trees
How is Gini Impurity Calculated?
A node’s gini attribute measures its impurity: a node is
● “Pure” (gini=0) if all training instances it applies to belong to the same
class.
A Gini coefficient of 1 expresses maximal inequality among the training
samples.
Machine Learning - Classfication
Decision Trees
How is Gini Impurity Calculated?
The formula for finding the gini impurity score of a particular level is :
Here pi is the ratio of class i in the node whose gini index is being calculated.
There are total of c classes.
Machine Learning - Classfication
Decision Trees
How is Gini Impurity Calculated?
For example, since the depth-1
left node applies only to Iris-
Setosa training instances, it is
pure and its gini score is 0.
Machine Learning - Classfication
Decision Trees
How is Gini Impurity Calculated?
In the our example the depth-2
left node has a gini score equal to
1 – (0/54)2 – (49/54)2 – (5/54)2 ≈
0.168

Recommended for you

Decision tree
Decision tree Decision tree
Decision tree

A decision tree is a guide to the potential results of a progression of related choices. It permits an individual or association to gauge potential activities against each other dependent on their costs, probabilities, and advantages. They can be utilized either to drive casual conversation or to outline a calculation that predicts the most ideal decision scientifically.

data science courses in bangalore | learnbaymachine learning training in bangaloredeep learning
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning

Basic of Decision Tree Learning. This slide includes definition of decision tree, basic example, basic construction of a decision tree, mathlab example

decision tree learningdecision tree learning basic exampledecision tree
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...

The document discusses decision trees and how they work. It begins with explaining what a decision tree is - a tree-shaped diagram used to determine a course of action, with each branch representing a possible decision. It then provides examples of using a decision tree to classify vegetables and animals based on their features. The document also covers key decision tree concepts like entropy, information gain, leaf nodes, decision nodes, and the root node. It demonstrates how a decision tree is built by choosing splits that maximize information gain. Finally, it presents a use case of using a decision tree to predict loan repayment.

machine learningmachine learning algorithmsdecision tree
Machine Learning - Classfication
Decision Trees
Model Interpretation : White Box versus Black Box
A White Box Model is :
● Fairly intuitive
● Their decisions are easy to interpret
● Eg. Decision Trees
Machine Learning - Classfication
Decision Trees
Model Interpretation : White Box versus Black Box
A Black Box Model is :
● They make great predictions
● Easy to check the calculations that were performed to make these
predictions
Machine Learning - Classfication
Decision Trees
Model Interpretation : White Box versus Black Box
A Black Box Model is :
● It is usually hard to explain in simple terms why the predictions were
made
● Eg. Random Forests , Neural networks
Machine Learning - Classfication
Model Interpretation : White Box versus Black Box
Decision Trees

Recommended for you

Mis End Term Exam Theory Concepts
Mis End Term Exam Theory ConceptsMis End Term Exam Theory Concepts
Mis End Term Exam Theory Concepts

The document provides an overview of concepts and topics to be covered in the MIS End Term Exam for AI and A2 on February 6th 2020, including: decision trees, classifier algorithms like ID3, CART and Naive Bayes; supervised and unsupervised learning; clustering using K-means; bias and variance; overfitting and underfitting; ensemble learning techniques like bagging and random forests; and the use of test and train data.

Module 5: Decision Trees
Module 5: Decision TreesModule 5: Decision Trees
Module 5: Decision Trees

Delta Analytics is a 501(c)3 non-profit in the Bay Area. We believe that data is powerful, and that anybody should be able to harness it for change. Our teaching fellows partner with schools and organizations worldwide to work with students excited about the power of data to do good. Welcome to the course! These modules will teach you the fundamental building blocks and the theory necessary to be a responsible machine learning practitioner in your own community. Each module focuses on accessible examples designed to teach you about good practices and the powerful (yet surprisingly simple) algorithms we use to model data. To learn more about our mission or provide feedback, take a look at www.deltanalytics.org.

machine learningdata for goodnonprofit
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdfMachine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf

Its all about Machine learning .Machine learning is a field of artificial intelligence (AI) that focuses on the development of algorithms and statistical models that enable computers to perform tasks without explicit programming instructions. Instead, these algorithms learn from data, identifying patterns, and making decisions or predictions based on that data. There are several types of machine learning approaches, including: Supervised Learning: In this approach, the algorithm learns from labeled data, where each example is paired with a label or outcome. The algorithm aims to learn a mapping from inputs to outputs, such as classifying emails as spam or not spam. Unsupervised Learning: Here, the algorithm learns from unlabeled data, seeking to find hidden patterns or structures within the data. Clustering algorithms, for instance, group similar data points together without any predefined labels. Semi-Supervised Learning: This approach combines elements of supervised and unsupervised learning, typically by using a small amount of labeled data along with a large amount of unlabeled data to improve learning accuracy. Reinforcement Learning: This paradigm involves an agent learning to make decisions by interacting with an environment. The agent receives feedback in the form of rewards or penalties, enabling it to learn the optimal behavior to maximize cumulative rewards over time.Machine learning algorithms can be applied to a wide range of tasks, including: Classification: Assigning inputs to one of several categories. For example, classifying whether an email is spam or not. Regression: Predicting a continuous value based on input features. For instance, predicting house prices based on features like square footage and location. Clustering: Grouping similar data points together based on their characteristics. Dimensionality Reduction: Reducing the number of input variables to simplify analysis and improve computational efficiency. Recommendation Systems: Predicting user preferences and suggesting items or actions accordingly. Natural Language Processing (NLP): Analyzing and generating human language text, enabling tasks like sentiment analysis, machine translation, and text summarization. Machine learning has numerous applications across various domains, including healthcare, finance, marketing, cybersecurity, and more. It continues to be an area of active research and

machine learningtechnologycomputer
Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
A Decision Tree can also estimate the probability that an instance belongs to
a particular class k.
To do this it follows the following steps:
● First it traverses the tree to find the leaf node for this instance
● Then it returns the ratio of training instances of class k in this node.
Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
Suppose you have found a flower
whose petals are
● 5 cm long and
● 1.5 cm wide
Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
It first asks the question whether
petal length <= 2.45. Since the
condition is false it will go to the
right subset
Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
It will then ask if petal width <=
1.75. Since the condition is true it
will go the left subset.

Recommended for you

Machine learning and decision trees
Machine learning and decision treesMachine learning and decision trees
Machine learning and decision trees

It gives a very detailed introduction about machine learning and decision tree construction. Python code for decision tree classifier.

decision treemachine learningpython code for decision tree
Barga Data Science lecture 4
Barga Data Science lecture 4Barga Data Science lecture 4
Barga Data Science lecture 4

This document outlines an agenda for a data science boot camp covering various machine learning topics over several hours. The agenda includes discussions of decision trees, ensembles, random forests, data modelling, and clustering. It also provides examples of data leakage problems and discusses the importance of evaluating model performance. Homework assignments involve building models with Weka and identifying the minimum attributes needed to distinguish between red and white wines.

analyticsmachine learningdata mining
Dbm630 lecture06
Dbm630 lecture06Dbm630 lecture06
Dbm630 lecture06

The document discusses classification and prediction using decision trees. It begins by defining classification as predicting categorical labels from data, such as predicting if a loan applicant is "safe" or "risky". Prediction involves predicting continuous or ordered values, such as how much a customer will spend. The document then discusses how decision trees perform classification by recursively splitting the data into purer subsets based on attribute values, with leaf nodes representing class labels. Information gain is used as the splitting criterion to select the attribute that best splits the data. Finally, it notes that attributes with many values can bias decision trees towards overfitting.

Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
Decision Tree should output the
following probabilities:
● 0% for Iris-Setosa (0/54)
● 90.7% for Iris-Versicolor
(49/54)
● 9.3% for Iris- Virginica (5/54)
Machine Learning - Classfication
Decision Trees
Estimating Class Probabilities
If we ask it to predict the class, it should output Iris-Versicolor (class 1) since
it has the highest probability.
Let’s verify it:
>>> tree_clf.predict_proba([[5, 1.5]])
array([[ 0. , 0.90740741, 0.09259259]])
>>> tree_clf.predict([[5, 1.5]])
array([1])
Run it in jupyter notebook
Machine Learning - Classfication
The CART Training Algorithm
Decision Trees
Scikit-Learn uses the Classification And Regression Tree (CART) algorithm
to train Decision Trees.
The idea is really quite simple:
● The algorithm first splits the training set in two subsets using a single
feature k and a threshold tk
Machine Learning - Classfication
Decision Trees
The CART Training Algorithm
How does it choose k and tk???
It searches for the pair (k, tk) that produces the purest subsets (weighted by
their size) Splitting on the basis
of feature k and a
threshold value of tk
Purest
Subset
Purest
Subset

Recommended for you

Introduction to Random Forest
Introduction to Random Forest Introduction to Random Forest
Introduction to Random Forest

Get to know in detail the termonologies of Random Forest with their types of algorithms used in the workflow along with their advantages and disadvantages of their predecessors. Thanks, for your time, if you enjoyed this short article there are tons of topics in advanced analytics, data science, and machine learning available in my medium repo. https://medium.com/@bobrupakroy

ensemble methodsmachine learningartificial intelligence
Unit 2-ML.pptx
Unit 2-ML.pptxUnit 2-ML.pptx
Unit 2-ML.pptx

The document provides an introduction to supervised learning. It discusses how supervised learning models are trained on labelled datasets containing both input data and corresponding results or labels. The model learns from these examples to predict accurate results for new, unseen data. Common applications of supervised learning mentioned include sentiment analysis, recommendations, and spam filtration. Decision trees and K-nearest neighbors are discussed as examples of supervised learning algorithms. Decision trees use a top-down approach to split the dataset into more homogeneous subsets. K-nearest neighbors classifies new data based on similarity to labelled examples in the training set.

classification in data warehouse and mining
classification in data warehouse and miningclassification in data warehouse and mining
classification in data warehouse and mining

classification in data mining

classificationdata mining
Machine Learning - Classfication
Decision Trees
The CART Training Algorithm
The cost function that the algorithm tries to minimize is given by the
equation :
Machine Learning - Classfication
Decision Trees
The CART Training Algorithm
● Once it has successfully split the training set in two, it splits the subsets
using the same logic, then the sub- subsets and so on, recursively
● It stops recursion once it reaches the maximum depth (defined by the
max_depth hyperparameter), or if it cannot find a split that will reduce
impurity.
Machine Learning - Classfication
Decision Trees
Important points on the CART Training Algorithm
● It is a greedy algorithm as it greedily searches for an optimum split at the
top level
● Then repeats the process at each level.
Splitting on the basis
of feature k and a
threshold value of tk
Purest
Subset
Purest
Subset
Machine Learning - Classfication
Decision Trees
Important points on the CART Training Algorithm
● It does not check whether or not the split will lead to the lowest possible
impurity several levels down.
● A greedy algorithm often produces a reasonably good solution, but it is
not guaranteed to be the optimal solution

Recommended for you

Supervised learning (2)
Supervised learning (2)Supervised learning (2)
Supervised learning (2)

This document describes using decision trees and linear regression for a statistical learning project on housing data. It discusses building decision trees and regression trees on latitude, longitude and other variables to predict housing prices. Linear regression performs poorly with an R-squared of 0.24, while regression trees more accurately identify areas with above-median home values. Further optimizing the regression tree with additional variables like income and population improves the model fit and predictions.

Decision tree presentation
Decision tree presentationDecision tree presentation
Decision tree presentation

This document discusses decision trees, which are supervised learning algorithms used for both classification and regression. It describes key decision tree concepts like decision nodes, leaves, splitting, and pruning. It also outlines different decision tree algorithms (ID3, C4.5, CART), attribute selection measures like Gini index and information gain, and the basic steps for implementing a decision tree in a programming language.

decision treemachine learningvisualization
Machine Learning - Decision Trees
Machine Learning - Decision TreesMachine Learning - Decision Trees
Machine Learning - Decision Trees

Detailed discussion about decision tree regressor and the classifier with finding the right algorithm to split Let me know if anything is required. Ping me at google #bobrupakroy

decision treesmachine learningalgorithms
Machine Learning - Classfication
Decision Trees
Computational Complexity of Decision Trees
Complexity of Prediction :
● Making predictions requires traversing the Decision Tree from the root
to a leaf.
● Decision Trees are generally approximately balanced, so traversing the
Decision Tree requires going through roughly O(log2(m)) nodes, where
m is total number of training instances.
Machine Learning - Classfication
Decision Trees
Computational Complexity of Decision Trees
Complexity of Prediction :
● Since each node only requires checking the value of one feature, the
overall prediction complexity is just O(log2(m))
One feature checked i.e. petal
length
One feature checked i.e. petal
width
Machine Learning - Classfication
Decision Trees
Computational Complexity of Decision Trees
Complexity of Prediction :
● Hence, the complexity of prediction is independent of the number of
features.
So predictions are very fast, even when dealing with large training sets.
Machine Learning - Classfication
Decision Trees
Computational Complexity of Decision Trees
Complexity of Training :
● The training algorithm compares all features (or less if max_features is
set) on all samples at each node.
● This results in a training complexity of O(n × m log(m)), where n is the
number of features, we have to compare all the n features at each of the
m nodes.

Recommended for you

[Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees [Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees

Decision trees are a supervised learning technique that can be used for both classification and regression problems. They work by recursively splitting a data set into purer and purer subsets based on an impurity measure, with the goal of ending up with subsets consisting of single class members. Common impurity measures include information gain and the GINI index. Decision trees can overfit data, so techniques like bagging and random forests are used to combine multiple decision trees to reduce variance.

datamachine learning
Understanding random forests
Understanding random forestsUnderstanding random forests
Understanding random forests

No machine learning algorithm dominates in every domain, but random forests are usually tough to beat by much. And they have some advantages compared to other models. No much input preparation needed, implicit feature selection, fast to train, and ability to visualize the model. While it is easy to get started with random forests, a good understanding of the model is key to get the most of them. This talk will cover decision trees from theory, to their implementation in scikit-learn. An overview of ensemble methods and bagging will follow, to end up explaining and implementing random forests and see how they compare to other state-of-the-art models. The talk will have a very practical approach, using examples and real cases to illustrate how to use both decision trees and random forests. We will see how the simplicity of decision trees, is a key advantage compared to other methods. Unlike black-box methods, or methods tough to represent in multivariate cases, decision trees can easily be visualized, analyzed, and debugged, until we see that our model is behaving as expected. This exercise can increase our understanding of the data and the problem, while making our model perform in the best possible way. Random Forests can randomize and ensemble decision trees to increase its predictive power, while keeping most of their properties. The main topics covered will include: * What are decision trees? * How decision trees are trained? * Understanding and debugging decision trees * Ensemble methods * Bagging * Random Forests * When decision trees and random forests should be used? * Python implementation with scikit-learn * Analysis of performance

data miningcartrandom forest
20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx

ensemble methods use multiple learning algorithms to obtain better predictive performance than could be obtained from any of the constituent learning algorithms alone. An ensemble is itself a supervised learning algorithm, because it can be trained and then used to make predictions. The trained ensemble, therefore, represents a single hypothesis. This hypothesis, however, is not necessarily contained within the hypothesis space of the models from which it is built.

machine learning
Machine Learning - Classfication
Decision Trees
Computational Complexity of Decision Trees
Complexity of Training :
For small training sets (less than a few thousand instances),
Scikit-Learn can speed up training by presorting the data (set presort=True),
but this slows down training considerably for larger training sets.
Machine Learning - Classfication
Decision Trees
Which measure to use ? Gini Impurity or Entropy?
By default, the Gini impurity measure is used, but you can select the entropy
impurity measure instead by setting the criterion hyperparameter to
"entropy".
Entropy measures the degree of randomness
Machine Learning - Classfication
Decision Trees
Which measure to use ? Gini Impurity or Entropy?
The formula for measuring entropy is
Machine Learning - Classfication
Decision Trees
Which measure to use ? Gini Impurity or Entropy?
The entropy for the
depth-2 left node is
≈ 0.31

Recommended for you

Know How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdfKnow How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdf

Creating and visualizing decision trees can be simple if one possesses the knowledge of the basics. Understand how to do it with the help of Python.

decision tree visualizationdecision treesdecision tree in python
Understanding computer vision with Deep Learning
Understanding computer vision with Deep LearningUnderstanding computer vision with Deep Learning
Understanding computer vision with Deep Learning

Computer vision is a branch of computer science which deals with recognising objects, people and identifying patterns in visuals. It is basically analogous to the vision of an animal. Topics covered: 1. Overview of Machine Learning 2. Basics of Deep Learning 3. What is computer vision and its use-cases? 4. Various algorithms used in Computer Vision (mostly CNN) 5. Live hands-on demo of either Auto Cameraman or Face recognition system 6. What next?

computer visionmachine learningbig data
Deep Learning Overview
Deep Learning OverviewDeep Learning Overview
Deep Learning Overview

This document provides an agenda for an introduction to deep learning presentation. It begins with an introduction to basic AI, machine learning, and deep learning terms. It then briefly discusses use cases of deep learning. The document outlines how to approach a deep learning problem, including which tools and algorithms to use. It concludes with a question and answer section.

cloudxlabdeep learningmachine learning
Machine Learning - Classfication
Decision Trees
Which measure to use ? Gini Impurity or Entropy?
The truth is, most of the time it does not make a big difference: they lead to
similar trees.
● Gini impurity is slightly faster to compute, so it is a good default.
● However, Gini impurity tends to isolate the most frequent class in its own
branch of the tree
● While entropy tends to produce slightly more balanced trees.
Machine Learning - Classfication
Decision Trees
Regularization Hyperparameter
● If left unconstrained, the tree structure will adapt itself to the training
data, fitting it very closely, and most likely overfitting it.
● To avoid overfitting the training data, you need to restrict the Decision
Tree’s freedom during training.
Machine Learning - Classfication
Decision Trees
Regularization Hyperparameter
● Putting restriction on the freedom of the model during training is called
regularization. The regularization hyperparameters depend on the
algorithm used, but generally you can at least restrict the maximum depth
of the Decision Tree.
Machine Learning - Classfication
Decision Trees
Parametric and Non-parametric models
● Models like Decision Tree models are often called nonparametric
model because the number of parameters is not determined prior to
training, so the model structure is free to stick closely to the data.
● In contrast, a parametric model such as a linear model has a
predetermined number of parameters, so its degree of freedom is limited,
reducing the risk of overfitting but increasing the risk of underfitting.

Recommended for you

Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural Networks

This document discusses recurrent neural networks (RNNs) and their applications. It begins by explaining that RNNs can process input sequences of arbitrary lengths, unlike other neural networks. It then provides examples of RNN applications, such as predicting time series data, autonomous driving, natural language processing, and music generation. The document goes on to describe the fundamental concepts of RNNs, including recurrent neurons, memory cells, and different types of RNN architectures for processing input/output sequences. It concludes by demonstrating how to implement basic RNNs using TensorFlow's static_rnn function.

recurrent neural networkrecurrent neural network tutorialrecurrent neural network tensorflow
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing

Natural Language Processing (NLP) is a field of artificial intelligence that deals with interactions between computers and human languages. NLP aims to program computers to process and analyze large amounts of natural language data. Some common NLP tasks include speech recognition, text classification, machine translation, question answering, and more. Popular NLP tools include Stanford CoreNLP, NLTK, OpenNLP, and TextBlob. Vectorization is commonly used to represent text in a way that can be used for machine learning algorithms like calculating text similarity. Tf-idf is a common technique used to weigh words based on their frequency and importance.

cloudxlabdeep learningmachine learning
Naive Bayes
Naive BayesNaive Bayes
Naive Bayes

- Naive Bayes is a classification technique based on Bayes' theorem that uses "naive" independence assumptions. It is easy to build and can perform well even with large datasets. - It works by calculating the posterior probability for each class given predictor values using the Bayes theorem and independence assumptions between predictors. The class with the highest posterior probability is predicted. - It is commonly used for text classification, spam filtering, and sentiment analysis due to its fast performance and high success rates compared to other algorithms.

cloudxlabdeep learningmachine learning
Machine Learning - Classfication
Decision Trees
Regularization parameters for DecisionTreeClassifier class
● max_depth → restricts the maximum depth of the Decision Tree
● min_samples_split → the minimum number of samples a node must
have before it can be split
● min_samples_leaf → the minimum number of samples a leaf node must
have
Machine Learning - Classfication
Decision Trees
Regularization parameters for DecisionTreeClassifier class
● min_weight_fraction_leaf → same as min_samples_leaf but expressed
as a fraction of the total number of weighted instances
● max_leaf_nodes → maximum number of leaf nodes
● max_features → maximum number of features that are evaluated for
splitting at each node
Increasing min_* hyperparameters or reducing max_*
hyperparameters will regularize the model.
Machine Learning - Classfication
Decision Trees
Regularization parameters for DecisionTreeClassifier class
The above Decision Tree is trained with the default hyperparameters i.e., no
restrictions. This model is Overfitting the data.
Machine Learning - Classfication
Decision Trees
Regularization parameters for DecisionTreeClassifier class
The above Decision Tree is trained with min_samples_leaf=4. This model
will probably generalize better.

Recommended for you

Autoencoders
AutoencodersAutoencoders
Autoencoders

An autoencoder is an artificial neural network that is trained to copy its input to its output. It consists of an encoder that compresses the input into a lower-dimensional latent-space encoding, and a decoder that reconstructs the output from this encoding. Autoencoders are useful for dimensionality reduction, feature learning, and generative modeling. When constrained by limiting the latent space or adding noise, autoencoders are forced to learn efficient representations of the input data. For example, a linear autoencoder trained with mean squared error performs principal component analysis.

autoencoderdenoising autoencodervariational autoencoder
Training Deep Neural Nets
Training Deep Neural NetsTraining Deep Neural Nets
Training Deep Neural Nets

The document discusses challenges in training deep neural networks and solutions to those challenges. Training deep neural networks with many layers and parameters can be slow and prone to overfitting. A key challenge is the vanishing gradient problem, where the gradients shrink exponentially small as they propagate through many layers, making earlier layers very slow to train. Solutions include using initialization techniques like He initialization and activation functions like ReLU and leaky ReLU that do not saturate, preventing gradients from vanishing. Later improvements include the ELU activation function.

vanishing gradientvanishing gradient problemxavier initialization
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning

( Machine Learning & Deep Learning Specialization Training: https://goo.gl/5u2RiS ) This CloudxLab Reinforcement Learning tutorial helps you to understand Reinforcement Learning in detail. Below are the topics covered in this tutorial: 1) What is Reinforcement? 2) Reinforcement Learning an Introduction 3) Reinforcement Learning Example 4) Learning to Optimize Rewards 5) Policy Search - Brute Force Approach, Genetic Algorithms and Optimization Techniques 6) OpenAI Gym 7) The Credit Assignment Problem 8) Inverse Reinforcement Learning 9) Playing Atari with Deep Reinforcement Learning 10) Policy Gradients 11) Markov Decision Processes

reinforcement learningopenai gymwhat is reinforcement
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
Decision Trees are also capable of performing regression tasks. Let’s build a
regression tree using Scikit- Learn’s DecisionTreeRegressor class, training it
on a noisy quadratic dataset with max_depth=2
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
>>> from sklearn.tree import DecisionTreeRegressor
>>> tree_reg = DecisionTreeRegressor(max_depth=2)
tree_reg.fit(X, y)
Run it on Notebook
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
The main difference is that instead of predicting a class in each node, it
predicts a value.
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
Notice how the predicted value for each region is always the average target
value of the instances in that region.

Recommended for you

Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...

The document provides information about key-value RDD transformations and actions in Spark. It defines transformations like keys(), values(), groupByKey(), combineByKey(), sortByKey(), subtractByKey(), join(), leftOuterJoin(), rightOuterJoin(), and cogroup(). It also defines actions like countByKey() and lookup() that can be performed on pair RDDs. Examples are given showing how to use these transformations and actions to manipulate key-value RDDs.

spark transformationsspark combinebykeyspark join
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabAdvanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab

Big Data with Hadoop & Spark Training: http://bit.ly/2kyRTuW This CloudxLab Advanced Spark Programming tutorial helps you to understand Advanced Spark Programming in detail. Below are the topics covered in this slide: 1) Shared Variables - Accumulators & Broadcast Variables 2) Accumulators and Fault Tolerance 3) Custom Accumulators - Version 1.x & Version 2.x 4) Examples of Broadcast Variables 5) Key Performance Considerations - Level of Parallelism 6) Serialization Format - Kryo 7) Memory Management 8) Hardware Provisioning

spark accumulatoraccumulators in sparkspark broadcast variable
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...

Big Data with Hadoop & Spark Training: http://bit.ly/2sm9c61 This CloudxLab Introduction to Spark SQL & DataFrames tutorial helps you to understand Spark SQL & DataFrames in detail. Below are the topics covered in this slide: 1) Loading XML 2) What is RPC - Remote Process Call 3) Loading AVRO 4) Data Sources - Parquet 5) Creating DataFrames From Hive Table 6) Setting up Distributed SQL Engine

spark dataframespark dataframe apidataframe spark
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
The CART algorithm works the same way except instead of trying to split
the training set in a way that minimizes impurity, it now tries to split the
training set in a way that minimizes the MSE.
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
The formula for cost function for regression is -
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
● Just like for classification tasks, Decision Trees are prone to overfitting
when dealing with regression tasks.
● Without any regularization the model may overfit the data.
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
Without any regularization i.e., using the default hyperparameters, you get
the above model.
It is obviously overfitting the training set very badly.

Recommended for you

Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...

Big Data with Hadoop & Spark Training: http://bit.ly/2sf2z6i This CloudxLab Introduction to Spark SQL & DataFrames tutorial helps you to understand Spark SQL & DataFrames in detail. Below are the topics covered in this slide: 1) Introduction to DataFrames 2) Creating DataFrames from JSON 3) DataFrame Operations 4) Running SQL Queries Programmatically 5) Datasets 6) Inferring the Schema Using Reflection 7) Programmatically Specifying the Schema

spark dataframespark dataframe apidataframe spark
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLabApache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab

(Big Data with Hadoop & Spark Training: http://bit.ly/2IUsWca This CloudxLab Running in a Cluster tutorial helps you to understand running Spark in the cluster in detail. Below are the topics covered in this tutorial: 1) Spark Runtime Architecture 2) Driver Node 3) Scheduling Tasks on Executors 4) Understanding the Architecture 5) Cluster Managers 6) Executors 7) Launching a Program using spark-submit 8) Local Mode & Cluster-Mode 9) Installing Standalone Cluster 10) Cluster Mode - YARN 11) Launching a Program on YARN 12) Cluster Mode - Mesos and AWS EC2 13) Deployment Modes - Client and Cluster 14) Which Cluster Manager to Use? 15) Common flags for spark-submit

spark executor memoryspark architecturespark executor
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab

Big Data with Hadoop & Spark Training: http://bit.ly/2LCTufA This CloudxLab Introduction to SparkR tutorial helps you to understand SparkR in detail. Below are the topics covered in this tutorial: 1) SparkR (R on Spark) 2) SparkR DataFrames 3) Launch SparkR 4) Creating DataFrames from Local DataFrames 5) DataFrame Operation 6) Creating DataFrames - From JSON 7) Running SQL Queries from SparkR

sparkrsparkr tutorialbig data analytics
Machine Learning - Classfication
Decision Trees
Regression with Decision Trees
Just setting min_samples_leaf=10 results in a much more reasonable model,
represented by the above figure.
Machine Learning - Classfication
Decision Trees
Demerits of Decision Trees
● Decision Trees love orthogonal decision boundaries (all splits are
perpendicular to an axis)
● This makes them sensitive to training set rotation.
● They are very sensitive to small variations in the training data.
Machine Learning - Classfication
Decision Trees
Demerits of Decision Trees
Above figure shows a simple linearly separable dataset: on the left, a Decision
Tree can split it easily, while on the right, after the dataset is rotated by 45°,
the decision boundary looks unnecessarily convoluted.
Machine Learning - Classfication
Decision Trees
Demerits of Decision Trees
Although both Decision Trees fit the training set perfectly, it is very likely
that the model on the right will not generalize well.

Recommended for you

Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab

1) NoSQL databases are non-relational and schema-free, providing alternatives to SQL databases for big data and high availability applications. 2) Common NoSQL database models include key-value stores, column-oriented databases, document databases, and graph databases. 3) The CAP theorem states that a distributed data store can only provide two out of three guarantees around consistency, availability, and partition tolerance.

nosqlnosql databasemongodb
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...

Big Data with Hadoop & Spark Training: http://bit.ly/2sh5b3E This CloudxLab Hadoop Streaming tutorial helps you to understand Hadoop Streaming in detail. Below are the topics covered in this tutorial: 1) Hadoop Streaming and Why Do We Need it? 2) Writing Streaming Jobs 3) Testing Streaming jobs and Hands-on on CloudxLab

hadoop architecturewhat is mapreducemap reduce
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabIntroduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab

This document provides instructions for getting started with TensorFlow using a free CloudxLab. It outlines the following steps: 1. Open CloudxLab and enroll if not already enrolled. Otherwise go to "My Lab". 2. In "My Lab", open Jupyter and run commands to clone an ML repository containing TensorFlow examples. 3. Go to the deep learning folder in Jupyter and open the TensorFlow notebook to get started with examples.

deep learningtensorflowtensorflow tutorial
Questions?
https://discuss.cloudxlab.com
reachus@cloudxlab.com
Thank You
reachus@cloudxlab.com

More Related Content

What's hot

Introduction to Transformers for NLP - Olga Petrova
Introduction to Transformers for NLP - Olga PetrovaIntroduction to Transformers for NLP - Olga Petrova
Introduction to Transformers for NLP - Olga Petrova
Alexey Grigorev
 
Dimensionality reduction with UMAP
Dimensionality reduction with UMAPDimensionality reduction with UMAP
Dimensionality reduction with UMAP
Jakub Bartczuk
 
An Introduction to Neural Architecture Search
An Introduction to Neural Architecture SearchAn Introduction to Neural Architecture Search
An Introduction to Neural Architecture Search
Bill Liu
 
Word embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTMWord embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTM
Divya Gera
 
Recurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: TheoryRecurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: Theory
Andrii Gakhov
 
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Edureka!
 
Recurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRURecurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRU
ananth
 
Neural Networks: Support Vector machines
Neural Networks: Support Vector machinesNeural Networks: Support Vector machines
Neural Networks: Support Vector machines
Mostafa G. M. Mostafa
 
CNN Tutorial
CNN TutorialCNN Tutorial
CNN Tutorial
Sungjoon Choi
 
Beginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix FactorizationBeginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix Factorization
Benjamin Bengfort
 
Hyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine LearningHyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine Learning
Francesco Casalegno
 
Ensemble methods
Ensemble methodsEnsemble methods
Ensemble methods
Christopher Marker
 
Document clustering and classification
Document clustering and classification Document clustering and classification
Document clustering and classification
Mahmoud Alfarra
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Simplilearn
 
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Edureka!
 
Random forest algorithm
Random forest algorithmRandom forest algorithm
Random forest algorithm
Rashid Ansari
 
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingBERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Minh Pham
 
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
Universitat Politècnica de Catalunya
 
Mobilenetv1 v2 slide
Mobilenetv1 v2 slideMobilenetv1 v2 slide
Mobilenetv1 v2 slide
威智 黃
 
Rnn and lstm
Rnn and lstmRnn and lstm
Rnn and lstm
Shreshth Saxena
 

What's hot (20)

Introduction to Transformers for NLP - Olga Petrova
Introduction to Transformers for NLP - Olga PetrovaIntroduction to Transformers for NLP - Olga Petrova
Introduction to Transformers for NLP - Olga Petrova
 
Dimensionality reduction with UMAP
Dimensionality reduction with UMAPDimensionality reduction with UMAP
Dimensionality reduction with UMAP
 
An Introduction to Neural Architecture Search
An Introduction to Neural Architecture SearchAn Introduction to Neural Architecture Search
An Introduction to Neural Architecture Search
 
Word embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTMWord embeddings, RNN, GRU and LSTM
Word embeddings, RNN, GRU and LSTM
 
Recurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: TheoryRecurrent Neural Networks. Part 1: Theory
Recurrent Neural Networks. Part 1: Theory
 
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
 
Recurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRURecurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRU
 
Neural Networks: Support Vector machines
Neural Networks: Support Vector machinesNeural Networks: Support Vector machines
Neural Networks: Support Vector machines
 
CNN Tutorial
CNN TutorialCNN Tutorial
CNN Tutorial
 
Beginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix FactorizationBeginners Guide to Non-Negative Matrix Factorization
Beginners Guide to Non-Negative Matrix Factorization
 
Hyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine LearningHyperparameter Optimization for Machine Learning
Hyperparameter Optimization for Machine Learning
 
Ensemble methods
Ensemble methodsEnsemble methods
Ensemble methods
 
Document clustering and classification
Document clustering and classification Document clustering and classification
Document clustering and classification
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
 
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
Decision Tree Algorithm | Decision Tree in Python | Machine Learning Algorith...
 
Random forest algorithm
Random forest algorithmRandom forest algorithm
Random forest algorithm
 
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingBERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
 
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
End-to-end Speech Recognition with Recurrent Neural Networks (D3L6 Deep Learn...
 
Mobilenetv1 v2 slide
Mobilenetv1 v2 slideMobilenetv1 v2 slide
Mobilenetv1 v2 slide
 
Rnn and lstm
Rnn and lstmRnn and lstm
Rnn and lstm
 

Similar to Decision Trees

Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
zohebmusharraf
 
Decision tree
Decision tree Decision tree
Decision tree
Learnbay Datascience
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
Md. Ariful Hoque
 
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Simplilearn
 
Mis End Term Exam Theory Concepts
Mis End Term Exam Theory ConceptsMis End Term Exam Theory Concepts
Mis End Term Exam Theory Concepts
Vidya sagar Sharma
 
Module 5: Decision Trees
Module 5: Decision TreesModule 5: Decision Trees
Module 5: Decision Trees
Sara Hooker
 
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdfMachine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
AdityaSoraut
 
Machine learning and decision trees
Machine learning and decision treesMachine learning and decision trees
Machine learning and decision trees
Padma Metta
 
Barga Data Science lecture 4
Barga Data Science lecture 4Barga Data Science lecture 4
Barga Data Science lecture 4
Roger Barga
 
Dbm630 lecture06
Dbm630 lecture06Dbm630 lecture06
Introduction to Random Forest
Introduction to Random Forest Introduction to Random Forest
Introduction to Random Forest
Rupak Roy
 
Unit 2-ML.pptx
Unit 2-ML.pptxUnit 2-ML.pptx
Unit 2-ML.pptx
Chitrachitrap
 
classification in data warehouse and mining
classification in data warehouse and miningclassification in data warehouse and mining
classification in data warehouse and mining
anjanasharma77573
 
Supervised learning (2)
Supervised learning (2)Supervised learning (2)
Supervised learning (2)
AlexAman1
 
Decision tree presentation
Decision tree presentationDecision tree presentation
Decision tree presentation
Vijay Yadav
 
Machine Learning - Decision Trees
Machine Learning - Decision TreesMachine Learning - Decision Trees
Machine Learning - Decision Trees
Rupak Roy
 
[Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees [Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees
Nikolaos Vergos
 
Understanding random forests
Understanding random forestsUnderstanding random forests
Understanding random forests
Marc Garcia
 
20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx
RaflyRizky2
 
Know How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdfKnow How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdf
Data Science Council of America
 

Similar to Decision Trees (20)

Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
 
Decision tree
Decision tree Decision tree
Decision tree
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
 
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
 
Mis End Term Exam Theory Concepts
Mis End Term Exam Theory ConceptsMis End Term Exam Theory Concepts
Mis End Term Exam Theory Concepts
 
Module 5: Decision Trees
Module 5: Decision TreesModule 5: Decision Trees
Module 5: Decision Trees
 
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdfMachine Learning Unit-5 Decesion Trees & Random Forest.pdf
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
 
Machine learning and decision trees
Machine learning and decision treesMachine learning and decision trees
Machine learning and decision trees
 
Barga Data Science lecture 4
Barga Data Science lecture 4Barga Data Science lecture 4
Barga Data Science lecture 4
 
Dbm630 lecture06
Dbm630 lecture06Dbm630 lecture06
Dbm630 lecture06
 
Introduction to Random Forest
Introduction to Random Forest Introduction to Random Forest
Introduction to Random Forest
 
Unit 2-ML.pptx
Unit 2-ML.pptxUnit 2-ML.pptx
Unit 2-ML.pptx
 
classification in data warehouse and mining
classification in data warehouse and miningclassification in data warehouse and mining
classification in data warehouse and mining
 
Supervised learning (2)
Supervised learning (2)Supervised learning (2)
Supervised learning (2)
 
Decision tree presentation
Decision tree presentationDecision tree presentation
Decision tree presentation
 
Machine Learning - Decision Trees
Machine Learning - Decision TreesMachine Learning - Decision Trees
Machine Learning - Decision Trees
 
[Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees [Women in Data Science Meetup ATX] Decision Trees
[Women in Data Science Meetup ATX] Decision Trees
 
Understanding random forests
Understanding random forestsUnderstanding random forests
Understanding random forests
 
20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx20211229120253D6323_PERT 06_ Ensemble Learning.pptx
20211229120253D6323_PERT 06_ Ensemble Learning.pptx
 
Know How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdfKnow How to Create and Visualize a Decision Tree with Python.pdf
Know How to Create and Visualize a Decision Tree with Python.pdf
 

More from CloudxLab

Understanding computer vision with Deep Learning
Understanding computer vision with Deep LearningUnderstanding computer vision with Deep Learning
Understanding computer vision with Deep Learning
CloudxLab
 
Deep Learning Overview
Deep Learning OverviewDeep Learning Overview
Deep Learning Overview
CloudxLab
 
Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural Networks
CloudxLab
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
CloudxLab
 
Naive Bayes
Naive BayesNaive Bayes
Naive Bayes
CloudxLab
 
Autoencoders
AutoencodersAutoencoders
Autoencoders
CloudxLab
 
Training Deep Neural Nets
Training Deep Neural NetsTraining Deep Neural Nets
Training Deep Neural Nets
CloudxLab
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
CloudxLab
 
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
CloudxLab
 
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabAdvanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
CloudxLab
 
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
CloudxLab
 
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLabApache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
CloudxLab
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabIntroduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
CloudxLab
 
Introduction to Deep Learning | CloudxLab
Introduction to Deep Learning | CloudxLabIntroduction to Deep Learning | CloudxLab
Introduction to Deep Learning | CloudxLab
CloudxLab
 
Dimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLabDimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLab
CloudxLab
 
Ensemble Learning and Random Forests
Ensemble Learning and Random ForestsEnsemble Learning and Random Forests
Ensemble Learning and Random Forests
CloudxLab
 

More from CloudxLab (20)

Understanding computer vision with Deep Learning
Understanding computer vision with Deep LearningUnderstanding computer vision with Deep Learning
Understanding computer vision with Deep Learning
 
Deep Learning Overview
Deep Learning OverviewDeep Learning Overview
Deep Learning Overview
 
Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural Networks
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Naive Bayes
Naive BayesNaive Bayes
Naive Bayes
 
Autoencoders
AutoencodersAutoencoders
Autoencoders
 
Training Deep Neural Nets
Training Deep Neural NetsTraining Deep Neural Nets
Training Deep Neural Nets
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
 
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
 
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabAdvanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
 
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
 
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 1 | Big Data Hadoop Spark Tutori...
 
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLabApache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Running on a Cluster | Big Data Hadoop Spark Tutorial | CloudxLab
 
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
 
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to NoSQL | Big Data Hadoop Spark Tutorial | CloudxLab
 
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
Introduction to MapReduce - Hadoop Streaming | Big Data Hadoop Spark Tutorial...
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabIntroduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
 
Introduction to Deep Learning | CloudxLab
Introduction to Deep Learning | CloudxLabIntroduction to Deep Learning | CloudxLab
Introduction to Deep Learning | CloudxLab
 
Dimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLabDimensionality Reduction | Machine Learning | CloudxLab
Dimensionality Reduction | Machine Learning | CloudxLab
 
Ensemble Learning and Random Forests
Ensemble Learning and Random ForestsEnsemble Learning and Random Forests
Ensemble Learning and Random Forests
 

Recently uploaded

20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
ScyllaDB
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 

Recently uploaded (20)

20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 

Decision Trees

  • 2. Machine Learning - Classfication Decision Trees In this session we’ll learn about Decision Trees. Decision Trees are versatile Machine Learning algorithms that can perform ● Classification Tasks ● Regression Tasks ● And even multi-output tasks They are very powerful algorithms, capable of fitting complex datasets. Also used in Random Forest (remember our project?)
  • 3. Machine Learning - Classfication Decision Trees Example of a Decision Tree
  • 4. Machine Learning - Classfication Decision Trees ● Working with Decision Trees ○ Train ○ Visualize ○ Make prediction with Decision tree ● The CART training algorithm used by Scikit-Learn ● How to regularize trees and use them for regression tasks ● Regression with Decision Trees ● Limitations of Decision Trees What we’ll learn in this session ?
  • 5. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree Let’s just build a Decision Tree and take a look at how it makes predictions We’ll train a DecisionTreeClassifier using Scikit Learn on the famous Iris dataset. And then we’ll see how it works.
  • 6. Machine Learning - Classfication Decision Trees Iris Dataset - Training and Visualizing a Decision Tree The iris dataset consists of 4 features namely : ● Petal Length ● Petal Width ● Sepal Length ● Sepal Width There are three classes namely : ● Iris Setosa ● Iris Versicolor ● Iris Virginica
  • 7. Machine Learning - Classfication Decision Trees Iris Dataset - Training and Visualizing a Decision Tree
  • 8. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree The iris dataset has 4 features petal length, petal width, sepal length and sepal width. But here we’ll only use two features i.e. petal length and petal width.
  • 9. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree We will follow the following steps to train and visualize our decision tree 1. Load the Iris dataset using Scikit Learn 2. Select only the Petal length and Petal width features 3. Train our Decision Tree classifier on the Iris Dataset 4. Visualize our Decision Tree using export_graphviz() 5. export_graphviz() gives us a file in .dot format which we will convert to png using the dot command line tool
  • 10. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree 1. Load the Iris dataset using Scikit Learn >>> from sklearn.datasets import load_iris >>> iris = load_iris() Run it in jupyter notebook
  • 11. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree 2. Select only the Petal length and Petal width features >>> X = iris.data[:, 2:] # petal length and width >>> y = iris.target Run it in jupyter notebook
  • 12. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree 3. Train our Decision Tree classifier on the Iris Dataset >>> from sklearn.tree import DecisionTreeClassifier >>> tree_clf = DecisionTreeClassifier(max_depth=2) >>> tree_clf.fit(X, y) Run it in jupyter notebook
  • 13. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree 4. Visualize our Decision Tree using export_graphviz() We can visualize the trained decision tree using the export_graphviz() method. >>> from sklearn.tree import export_graphviz >>> export_graphviz( tree_clf, out_file=image_path("iris_tree.dot"), feature_names=iris.feature_names[2:], class_names=iris.target_names, rounded=True, filled=True )
  • 14. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree 5. Converting to Png file Then you can convert this .dot file to a variety of formats such as PDF or PNG using the dot command- line tool from the graphviz package. This command line converts the .dot file to a .png image file: >>> dot -Tpng iris_tree.dot -o iris_tree.png Run it in the console
  • 15. Machine Learning - Classfication Decision Trees Training and Visualizing a Decision Tree
  • 16. Machine Learning - Classfication Decision Trees Understanding the Decision Tree A node’s value attribute tells you how many training instances of each class this node applies to for example, the bottom-right node applies to 0 Iris-Setosa, 1 Iris- Versicolor, and 45 Iris- Virginica.
  • 17. Machine Learning - Classfication Decision Trees Understanding the Decision Tree A node’s gini attribute measures its impurity: a node is “pure” (gini=0) if all training instances it applies to belong to the same class. For example, since the depth-1 left node applies only to Iris- Setosa training instances, it is pure and its gini score is 0.
  • 18. Machine Learning - Classfication Decision Trees Making Predictions To make a prediction the decision classifier follows these steps : ● Start at the root node (depth 0, at the top), this node asks whether the flower’s petal length is smaller than or equal to 2.45 cm:
  • 19. Machine Learning - Classfication Decision Trees Making Predictions ○ If it is, then you move down to the root’s left child node (depth 1, left). In this case it is a leaf node hence the flower is predicted as setosa.
  • 20. Machine Learning - Classfication Decision Trees Making Predictions ○ If it is not, then you move down to the root’s right child node (depth 1, right), since it is not a leaf node it asks further questions as, is the petal width smaller than or equal to 1.75 cm?
  • 21. Machine Learning - Classfication Decision Trees Making Predictions ● If it is, then your flower is most likely an Iris- Versicolor (depth 2, left). ● If it is not, If not, it is likely an Iris-Virginica (depth 2, right).
  • 22. Machine Learning - Classfication Decision Trees Decision Tree’s decision boundaries. Boundary made at depth 0. Petal length <= 2.45
  • 23. Machine Learning - Classfication Decision Trees Decision Tree’s decision boundaries. Boundary made at depth 1. Petal width <= 1.75
  • 24. Machine Learning - Classfication Decision Trees Decision Tree’s decision boundaries. This would have been the decision boundary to divide the tree further i.e. if max_depth was set to 3
  • 25. Machine Learning - Classfication Decision Trees How is Gini Impurity Calculated? A node’s gini attribute measures its impurity: a node is ● “Pure” (gini=0) if all training instances it applies to belong to the same class. A Gini coefficient of 1 expresses maximal inequality among the training samples.
  • 26. Machine Learning - Classfication Decision Trees How is Gini Impurity Calculated? The formula for finding the gini impurity score of a particular level is : Here pi is the ratio of class i in the node whose gini index is being calculated. There are total of c classes.
  • 27. Machine Learning - Classfication Decision Trees How is Gini Impurity Calculated? For example, since the depth-1 left node applies only to Iris- Setosa training instances, it is pure and its gini score is 0.
  • 28. Machine Learning - Classfication Decision Trees How is Gini Impurity Calculated? In the our example the depth-2 left node has a gini score equal to 1 – (0/54)2 – (49/54)2 – (5/54)2 ≈ 0.168
  • 29. Machine Learning - Classfication Decision Trees Model Interpretation : White Box versus Black Box A White Box Model is : ● Fairly intuitive ● Their decisions are easy to interpret ● Eg. Decision Trees
  • 30. Machine Learning - Classfication Decision Trees Model Interpretation : White Box versus Black Box A Black Box Model is : ● They make great predictions ● Easy to check the calculations that were performed to make these predictions
  • 31. Machine Learning - Classfication Decision Trees Model Interpretation : White Box versus Black Box A Black Box Model is : ● It is usually hard to explain in simple terms why the predictions were made ● Eg. Random Forests , Neural networks
  • 32. Machine Learning - Classfication Model Interpretation : White Box versus Black Box Decision Trees
  • 33. Machine Learning - Classfication Decision Trees Estimating Class Probabilities A Decision Tree can also estimate the probability that an instance belongs to a particular class k. To do this it follows the following steps: ● First it traverses the tree to find the leaf node for this instance ● Then it returns the ratio of training instances of class k in this node.
  • 34. Machine Learning - Classfication Decision Trees Estimating Class Probabilities Suppose you have found a flower whose petals are ● 5 cm long and ● 1.5 cm wide
  • 35. Machine Learning - Classfication Decision Trees Estimating Class Probabilities It first asks the question whether petal length <= 2.45. Since the condition is false it will go to the right subset
  • 36. Machine Learning - Classfication Decision Trees Estimating Class Probabilities It will then ask if petal width <= 1.75. Since the condition is true it will go the left subset.
  • 37. Machine Learning - Classfication Decision Trees Estimating Class Probabilities Decision Tree should output the following probabilities: ● 0% for Iris-Setosa (0/54) ● 90.7% for Iris-Versicolor (49/54) ● 9.3% for Iris- Virginica (5/54)
  • 38. Machine Learning - Classfication Decision Trees Estimating Class Probabilities If we ask it to predict the class, it should output Iris-Versicolor (class 1) since it has the highest probability. Let’s verify it: >>> tree_clf.predict_proba([[5, 1.5]]) array([[ 0. , 0.90740741, 0.09259259]]) >>> tree_clf.predict([[5, 1.5]]) array([1]) Run it in jupyter notebook
  • 39. Machine Learning - Classfication The CART Training Algorithm Decision Trees Scikit-Learn uses the Classification And Regression Tree (CART) algorithm to train Decision Trees. The idea is really quite simple: ● The algorithm first splits the training set in two subsets using a single feature k and a threshold tk
  • 40. Machine Learning - Classfication Decision Trees The CART Training Algorithm How does it choose k and tk??? It searches for the pair (k, tk) that produces the purest subsets (weighted by their size) Splitting on the basis of feature k and a threshold value of tk Purest Subset Purest Subset
  • 41. Machine Learning - Classfication Decision Trees The CART Training Algorithm The cost function that the algorithm tries to minimize is given by the equation :
  • 42. Machine Learning - Classfication Decision Trees The CART Training Algorithm ● Once it has successfully split the training set in two, it splits the subsets using the same logic, then the sub- subsets and so on, recursively ● It stops recursion once it reaches the maximum depth (defined by the max_depth hyperparameter), or if it cannot find a split that will reduce impurity.
  • 43. Machine Learning - Classfication Decision Trees Important points on the CART Training Algorithm ● It is a greedy algorithm as it greedily searches for an optimum split at the top level ● Then repeats the process at each level. Splitting on the basis of feature k and a threshold value of tk Purest Subset Purest Subset
  • 44. Machine Learning - Classfication Decision Trees Important points on the CART Training Algorithm ● It does not check whether or not the split will lead to the lowest possible impurity several levels down. ● A greedy algorithm often produces a reasonably good solution, but it is not guaranteed to be the optimal solution
  • 45. Machine Learning - Classfication Decision Trees Computational Complexity of Decision Trees Complexity of Prediction : ● Making predictions requires traversing the Decision Tree from the root to a leaf. ● Decision Trees are generally approximately balanced, so traversing the Decision Tree requires going through roughly O(log2(m)) nodes, where m is total number of training instances.
  • 46. Machine Learning - Classfication Decision Trees Computational Complexity of Decision Trees Complexity of Prediction : ● Since each node only requires checking the value of one feature, the overall prediction complexity is just O(log2(m)) One feature checked i.e. petal length One feature checked i.e. petal width
  • 47. Machine Learning - Classfication Decision Trees Computational Complexity of Decision Trees Complexity of Prediction : ● Hence, the complexity of prediction is independent of the number of features. So predictions are very fast, even when dealing with large training sets.
  • 48. Machine Learning - Classfication Decision Trees Computational Complexity of Decision Trees Complexity of Training : ● The training algorithm compares all features (or less if max_features is set) on all samples at each node. ● This results in a training complexity of O(n × m log(m)), where n is the number of features, we have to compare all the n features at each of the m nodes.
  • 49. Machine Learning - Classfication Decision Trees Computational Complexity of Decision Trees Complexity of Training : For small training sets (less than a few thousand instances), Scikit-Learn can speed up training by presorting the data (set presort=True), but this slows down training considerably for larger training sets.
  • 50. Machine Learning - Classfication Decision Trees Which measure to use ? Gini Impurity or Entropy? By default, the Gini impurity measure is used, but you can select the entropy impurity measure instead by setting the criterion hyperparameter to "entropy". Entropy measures the degree of randomness
  • 51. Machine Learning - Classfication Decision Trees Which measure to use ? Gini Impurity or Entropy? The formula for measuring entropy is
  • 52. Machine Learning - Classfication Decision Trees Which measure to use ? Gini Impurity or Entropy? The entropy for the depth-2 left node is ≈ 0.31
  • 53. Machine Learning - Classfication Decision Trees Which measure to use ? Gini Impurity or Entropy? The truth is, most of the time it does not make a big difference: they lead to similar trees. ● Gini impurity is slightly faster to compute, so it is a good default. ● However, Gini impurity tends to isolate the most frequent class in its own branch of the tree ● While entropy tends to produce slightly more balanced trees.
  • 54. Machine Learning - Classfication Decision Trees Regularization Hyperparameter ● If left unconstrained, the tree structure will adapt itself to the training data, fitting it very closely, and most likely overfitting it. ● To avoid overfitting the training data, you need to restrict the Decision Tree’s freedom during training.
  • 55. Machine Learning - Classfication Decision Trees Regularization Hyperparameter ● Putting restriction on the freedom of the model during training is called regularization. The regularization hyperparameters depend on the algorithm used, but generally you can at least restrict the maximum depth of the Decision Tree.
  • 56. Machine Learning - Classfication Decision Trees Parametric and Non-parametric models ● Models like Decision Tree models are often called nonparametric model because the number of parameters is not determined prior to training, so the model structure is free to stick closely to the data. ● In contrast, a parametric model such as a linear model has a predetermined number of parameters, so its degree of freedom is limited, reducing the risk of overfitting but increasing the risk of underfitting.
  • 57. Machine Learning - Classfication Decision Trees Regularization parameters for DecisionTreeClassifier class ● max_depth → restricts the maximum depth of the Decision Tree ● min_samples_split → the minimum number of samples a node must have before it can be split ● min_samples_leaf → the minimum number of samples a leaf node must have
  • 58. Machine Learning - Classfication Decision Trees Regularization parameters for DecisionTreeClassifier class ● min_weight_fraction_leaf → same as min_samples_leaf but expressed as a fraction of the total number of weighted instances ● max_leaf_nodes → maximum number of leaf nodes ● max_features → maximum number of features that are evaluated for splitting at each node Increasing min_* hyperparameters or reducing max_* hyperparameters will regularize the model.
  • 59. Machine Learning - Classfication Decision Trees Regularization parameters for DecisionTreeClassifier class The above Decision Tree is trained with the default hyperparameters i.e., no restrictions. This model is Overfitting the data.
  • 60. Machine Learning - Classfication Decision Trees Regularization parameters for DecisionTreeClassifier class The above Decision Tree is trained with min_samples_leaf=4. This model will probably generalize better.
  • 61. Machine Learning - Classfication Decision Trees Regression with Decision Trees Decision Trees are also capable of performing regression tasks. Let’s build a regression tree using Scikit- Learn’s DecisionTreeRegressor class, training it on a noisy quadratic dataset with max_depth=2
  • 62. Machine Learning - Classfication Decision Trees Regression with Decision Trees >>> from sklearn.tree import DecisionTreeRegressor >>> tree_reg = DecisionTreeRegressor(max_depth=2) tree_reg.fit(X, y) Run it on Notebook
  • 63. Machine Learning - Classfication Decision Trees Regression with Decision Trees The main difference is that instead of predicting a class in each node, it predicts a value.
  • 64. Machine Learning - Classfication Decision Trees Regression with Decision Trees Notice how the predicted value for each region is always the average target value of the instances in that region.
  • 65. Machine Learning - Classfication Decision Trees Regression with Decision Trees The CART algorithm works the same way except instead of trying to split the training set in a way that minimizes impurity, it now tries to split the training set in a way that minimizes the MSE.
  • 66. Machine Learning - Classfication Decision Trees Regression with Decision Trees The formula for cost function for regression is -
  • 67. Machine Learning - Classfication Decision Trees Regression with Decision Trees ● Just like for classification tasks, Decision Trees are prone to overfitting when dealing with regression tasks. ● Without any regularization the model may overfit the data.
  • 68. Machine Learning - Classfication Decision Trees Regression with Decision Trees Without any regularization i.e., using the default hyperparameters, you get the above model. It is obviously overfitting the training set very badly.
  • 69. Machine Learning - Classfication Decision Trees Regression with Decision Trees Just setting min_samples_leaf=10 results in a much more reasonable model, represented by the above figure.
  • 70. Machine Learning - Classfication Decision Trees Demerits of Decision Trees ● Decision Trees love orthogonal decision boundaries (all splits are perpendicular to an axis) ● This makes them sensitive to training set rotation. ● They are very sensitive to small variations in the training data.
  • 71. Machine Learning - Classfication Decision Trees Demerits of Decision Trees Above figure shows a simple linearly separable dataset: on the left, a Decision Tree can split it easily, while on the right, after the dataset is rotated by 45°, the decision boundary looks unnecessarily convoluted.
  • 72. Machine Learning - Classfication Decision Trees Demerits of Decision Trees Although both Decision Trees fit the training set perfectly, it is very likely that the model on the right will not generalize well.