Book Image

Learning Predictive Analytics with R

By : Eric Mayor
Book Image

Learning Predictive Analytics with R

By: Eric Mayor

Overview of this book

This book is packed with easy-to-follow guidelines that explain the workings of the many key data mining tools of R, which are used to discover knowledge from your data. You will learn how to perform key predictive analytics tasks using R, such as train and test predictive models for classification and regression tasks, score new data sets and so on. All chapters will guide you in acquiring the skills in a practical way. Most chapters also include a theoretical introduction that will sharpen your understanding of the subject matter and invite you to go further. The book familiarizes you with the most common data mining tools of R, such as k-means, hierarchical regression, linear regression, association rules, principal component analysis, multilevel modeling, k-NN, Naïve Bayes, decision trees, and text mining. It also provides a description of visualization techniques using the basic visualization tools of R as well as lattice for visualizing patterns in data organized in groups. This book is invaluable for anyone fascinated by the data mining opportunities offered by GNU R and its packages.
Table of Contents (23 chapters)
Learning Predictive Analytics with R
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Exercises and Solutions
Index

Installing the packages containing the required functions


Let's start by installing the different packages.

Installing C4.5

J48 is the implementation of C4.5 in Weka. It is readily available to R users through the RWeka package. Let's start by downloading and installing RWeka:

install.packages("RWeka"); library(RWeka)

This should work fine if the Java version (32 or 64 bit) matches the version of R that you are running. If the JAVA_HOME cannot be determined from the Registry error occurs, please install the correct Java version as explained at http://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/. The package discussed is the rJava package, but the advice given should work just fine for issues with RWeka too.

Installing C5.0

C5.0 is included in the C50 package, which we will install and load:

install.packages("C50"); library(C50)

Installing CART

The rpart() function of the rpart package allows us to run CART in R. Let's...