Book Image

Machine Learning with R Cookbook

By : Yu-Wei, Chiu (David Chiu)
Book Image

Machine Learning with R Cookbook

By: Yu-Wei, Chiu (David Chiu)

Overview of this book

<p>The R language is a powerful open source functional programming language. At its core, R is a statistical programming language that provides impressive tools to analyze data and create high-level graphics.</p> <p>This book covers the basics of R by setting up a user-friendly programming environment and performing data ETL in R. Data exploration examples are provided that demonstrate how powerful data visualization and machine learning is in discovering hidden relationships. You will then dive into important machine learning topics, including data classification, regression, clustering, association rule mining, and dimension reduction.</p>
Table of Contents (21 chapters)
Machine Learning with R Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Resources for R and Machine Learning
Dataset – Survival of Passengers on the Titanic
Index

Testing and debugging the rmr2 program


Since running a MapReduce program will require a considerable amount of time, varying from a few minutes to several hours, testing and debugging become very important. In this recipe, we will illustrate some techniques you can use to troubleshoot an R MapReduce program.

Getting ready

In this recipe, you should have completed the previous recipe by installing rmr2 into an R environment.

How to do it...

Perform the following steps to test and debug an R MapReduce program:

  1. First, you can configure the backend as local in rmr.options:

    > rmr.options(backend = 'local')
    
  2. Again, you can execute the number squared MapReduce program mentioned in the previous recipe:

    > b.time = proc.time() 
    > small.ints= to.dfs(1:100000) 
    > result = mapreduce(input = small.ints, map = function(k,v)       cbind(v,v^2)) 
    > proc.time() - b.time
    
  3. In addition to this, if you want to print the structure information of any variable in the MapReduce program, you can use the rmr...