Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Prediction using R

Has anyone successfully used the Google Predication API from within R? My goal is to perform the following tasks:

  • Upload and manage the data in Google Storage
  • Use this data to train a model from Google Prediction

I have followed the install instructions located here and here (when using Windows). I have not been able to successfully connect using both Mac OSX and Windows.

I suspect that the core issue is authentication. There is scattered documentation and I feel like I have tried everything (even the overview of the R package designed for this purpose).

I am not the greatest programmer, but I can typically follow along with code and piece together what I need from worked examples. At this point, though, I simply do not know what else to try.

Many thanks in advance.

like image 329
Btibert3 Avatar asked Sep 06 '12 13:09

Btibert3


2 Answers

Marc Cohen seems to be right, I think something is broken. However I managed to pass authentication, here is how:

Download the googlepredictionapi_0.12.tar.gz and extract it inside a temporary folder. Then open googlepredictionapi/R/prediction_api_init.R inside an Editor and remove the lines

myEmail <- ""
myPassword <- ""
myAPIkey <- ""

Afterwards repackage the source files and load them in R:

tar czf googlepredictionapi.mod.tar.gz googlepredictionapi
R
remove.packages("googlepredictionapi")

Now you should be able to follow the steps in [1] http://code.google.com/p/r-google-prediction-api-v12/. However instead of calling

install.packages("googlepredictionapi_0.12.tar.gz", repos=NULL, type="source")

you need to call

install.packages("googlepredictionapi.mod.tar.gz", repos=NULL, type="source")

Following the steps, at some point a file $HOME/.auth-token should be generated.

(You can even explicitly trigger this by calling explicitely: PredictionApiUtilGetAuth(verbose=TRUE), myEmail and myPassword must be set beforehands.)

For some reason the global variables that are manually set in [1] have been shadowed by the removed lines above. The same is actually true for the verbose option which you can pass to most API function calls as extra option ..., verbose=TRUE).

Hope this helps.

like image 175
Philip Avatar answered Oct 12 '22 17:10

Philip


Last I heard (April of this year), R support for the Google Prediction API was not yet upgraded to use OAuth so when the Prediction API switched from the older client login scheme to OAauth 2.0, it effectively broke R functionality.

like image 35
Marc Cohen Avatar answered Oct 12 '22 18:10

Marc Cohen