Reader small image

You're reading from  R Statistics Cookbook

Product typeBook
Published inMar 2019
Reading LevelExpert
PublisherPackt
ISBN-139781789802566
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Francisco Juretig
Francisco Juretig
author image
Francisco Juretig

Francisco Juretig has worked for over a decade in a variety of industries such as retail, gambling and finance deploying data-science solutions. He has written several R packages, and is a frequent contributor to the open source community.
Read more about Francisco Juretig

Right arrow

Preprocessing

The caret package allows us to do a variety of things for preprocessing our data, such as scaling, centering, removing variables with very low variability, and projecting it via principal components. The main workhorse for this is the preProcess() function.

In this recipe, we will explore how to undertake several data transformation steps, before modeling using the Boston dataset (included in the MASS package). This is a famous dataset containing house price indexes for several areas in Boston. The objective is to use several metrics for each area and predict the price index there. We will explain how to do it using random forests.

There are essentially two ways of doing this in caret:

  • By calling the preProcess= argument in the train function (this is less flexible, but can be used with cross-validation)
  • By calling the preProcess() function before calling train...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
R Statistics Cookbook
Published in: Mar 2019Publisher: PacktISBN-13: 9781789802566

Author (1)

author image
Francisco Juretig

Francisco Juretig has worked for over a decade in a variety of industries such as retail, gambling and finance deploying data-science solutions. He has written several R packages, and is a frequent contributor to the open source community.
Read more about Francisco Juretig