Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Predictive Analytics with R

You're reading from  Learning Predictive Analytics with R

Product type Book
Published in Sep 2015
Publisher Packt
ISBN-13 9781782169352
Pages 332 pages
Edition 1st Edition
Languages
Author (1):
Eric Mayor Eric Mayor
Profile icon Eric Mayor

Table of Contents (23) Chapters

Learning Predictive Analytics with R
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Setting GNU R for Predictive Analytics 2. Visualizing and Manipulating Data Using R 3. Data Visualization with Lattice 4. Cluster Analysis 5. Agglomerative Clustering Using hclust() 6. Dimensionality Reduction with Principal Component Analysis 7. Exploring Association Rules with Apriori 8. Probability Distributions, Covariance, and Correlation 9. Linear Regression 10. Classification with k-Nearest Neighbors and Naïve Bayes 11. Classification Trees 12. Multilevel Analyses 13. Text Analytics with R 14. Cross-validation and Bootstrapping Using Caret and Exporting Predictive Models Using PMML Exercises and Solutions Further Reading and References Index

Performing the analyses in R


Now that we have our data ready, we will focus on performing the analyses in R.

Classification with C4.5

We will first predict the income of the participants using C4.5.

The unpruned tree

We will start by examining the unpruned tree. This is configured using the Weka_Control(U= TRUE). J48() argument in RWeka, which uses the formula notation we have seen previously. The dot (.) after the tilde indicates that all attributes except the class attribute have to be used. We used the control argument to tell R that we want an unpruned tree (we will discuss pruning later):

C45tree = J48(income ~ . , data= AdultTrain,
   control= Weka_control(U=TRUE))

You can examine the tree by typing:

C45tree

We will not display it here as it is very big: the size of the tree is 5,715, with 4,683 leaves; but we can examine how well the tree classified the cases:

summary(C45tree)

The performance of the classifier on the training dataset

We can see that even though about 89 percent of cases are...

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}