My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

R client library for the Google Prediction API

Google develops this R package, googlepredictionapi, for R users to easily access the Google Prediction API.

Install

  1. Request access to the Google Prediction API (Click the Request Access link on the top right corner)
  2. Install prerequisite R packages: rjson, RCurl
  3. Install gsutil for accessing data in Google Storage
  4. Click here to download latest googlepredictionapi package
  5. Under R prompt,
  6. > install.packages("googlepredictionapi_0.1.tar.gz", repos=NULL, type="source")

Usage

## Load googlepredictionapi and dependent libraries
library(rjson)
library(RCurl)
library(googlepredictionapi)

## Make a training call to the Prediction API against data in the Google Storage.
## Replace MYBUCKET and MYDATA with your data.
my.model <- PredictionApiTrain(data="gs://MYBUCKET/MYDATA")

## Alternatively, make a training call against training data stored locally as a CSV file.
## Replace MYPATH and MYFILE with your local training file, and MYBUCKET with your own Google Storage buckets.
my.model <- PredictionApiTrain(data="MYPATH/MYFILE.csv", remote.file="gs://MYBUCKET/MYOBJECT")

## Read the summary of the trained model
summary(my.model)

## Make a prediction call for text data using the trained model
predict(my.model, "This is a new piece of text")

## Similarly, predict() works for numeric features
predict(my.model, c(6, 3, 5, 2))
Powered by Google Project Hosting