The Prediction service allows you to use the Google Prediction API in Apps Script. This API allows users to train prediction models and execute queries against them.
Reference
For detailed information on this service, see the reference documentation for the Prediction API. Like all advanced services in Apps Script, the Prediction service uses the same objects, methods, and parameters as the public API.
To report issues and find other support, see the Google+ support guide.
Sample code
The sample code below uses version 1.6 of the API.
Query a hosted model
This sample queries an example hosted model to analyze the sentiment of a text string.
Create and query a trained model
This sample implements the functionality of the Hello Prediction tutorial in Apps Script. It creates a new model and trains it with data from a comma-separated values (CSV) file uploaded to Google Cloud Storage in order to identify the language of a string of text.
Before executing these functions, please set up your project to use Google Cloud Storage by following the Prerequisites and Upload Training Data sections of the Hello Prediction tutorial. Note that you do not need to create a new API Console project because Apps Script automatically creates a project for you. To navigate to this project, open the script editor, then select the menu item Resources > Advanged Google services. Next, click the Google Developers Console link.
Create a new trained model
This code creates a new model and trains it using a CSV file uploaded to Google Cloud Storage.
Query training status
Because models are trained asynchronously, this code queries the status to find out when training is complete.
Query trained model
Once training is complete, this code queries the model to determine the language of the query string.