Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Machine Learning with R Quick Start Guide

You're reading from  Machine Learning with R Quick Start Guide

Product type Book
Published in Mar 2019
Publisher Packt
ISBN-13 9781838644338
Pages 250 pages
Edition 1st Edition
Languages
Author (1):
Iván Pastor Sanz Iván Pastor Sanz
Profile icon Iván Pastor Sanz

Implementing decision trees

When we looked at random forests in the Testing a random forest model section of chapter 5 (Predicting the Failures of Banks - Multivariate Analysis) previously, decision trees were briefly introduced. In a decision tree, the training sample is split into two or more homogeneous sets based on the most significant independent variables. In a decision tree, the best variable to split the data into the different categories is found. Information gain and the Gini index are the most common ways to find this variable. Then, data is recursively split, expanding the leaf nodes of the tree until the stopping criterion is reached.

Let's see how a decision tree can be implemented in R and how this algorithm is able to predict credit ratings.

Decision trees are implemented in the rpart package. Moreover, the rpart.plot package will be useful to visualize...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}