15

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.

Btibert3
  • 38,798
  • 44
  • 129
  • 168
  • 1
    Did you "manually authorize [GSUtil](https://code.google.com/apis/storage/docs/gsutil.html) ('gsutil config') and create .boto file" – GSee Sep 11 '12 at 15:25
  • Yes, as far as I know, everything should be good to go. On both machines, I followed the instructions to get GSUtils up and running as well as provided authorization. – Btibert3 Sep 11 '12 at 18:57
  • This is totally possible. You need to use `ROAuth` or `httr` to authenticate first before accessing the rest of the API. – Maiasaura Sep 15 '12 at 22:23
  • @Maiasaura - Can you provide some code as to how you would go about doing this? This is beyond what I know how to do. Thanks in advance! – Btibert3 Sep 18 '12 at 14:11
  • You're right, the authentication and using Google Cloud Storage are prohibitively difficult. – Colonel Panic Oct 12 '12 at 20:53
  • 2
    There's a Google Prediction API R client: http://code.google.com/p/google-prediction-api-r-client/ – A.M.K Oct 15 '12 at 02:24

2 Answers2

8

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.

Philip
  • 3,470
  • 7
  • 29
  • 42
2

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.

Marc Cohen
  • 3,742
  • 2
  • 19
  • 19