A R wrapper for Google Prediction API

November 8, 2010

(This article was first published on One R Tip A Day, and kindly contributed to R-bloggers)

Since I got the chance to access to both Google Storage for Developers and Google Prediction API (more details here and here), I decided to create a simple wrapper (just 4 basic functions until now) to be capable to play with the Google Prediction API from R.
Here you can find the github repository for the project and below few lines of code reproducing an example you can find on the Google Prediction API website.

Download the source code from here.
Either source the functions contained in the R directory or install the package typing (from the command line in a Unix-like environment):
R CMD INSTALL predictionapirwrapper_1.0.tar.gz
# start R and type (code highlighting thanks to Revolution Analytics Pretty R syntax highlighter):

## The first stage of using the API is to acquire an authorization token. This can be done via this command:
token <- GetAuthToken(email="[email protected]", passwd="mypassword")
## This command begins training on data that has been previously uploaded to Google Storage.
GoogleTrain(auth_token=token$Auth, mybucket="data_languages", mydata="language_id.txt")
## Once training has started, this command checks the status of the training job and gets meta-information on the model (if available).
GoogleTrainCheck(auth_token=token$Auth, mybucket="data_languages", mydata="language_id.txt")
## When training has finished, this command issues a request for a new prediction from the model. 
GooglePredict(auth_token=token$Auth, mybucket="data_languages", mydata="language_id.txt", myinput="La idioma mas fina")

All comments, corrections, alternative code are more than welcome!

Update: a more complete and functional alternative can be found here.

To leave a comment for the author, please follow the link and comment on their blog: One R Tip A Day.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



CRC R books series

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)