Skip to content

introduce Prediction API - #989

Merged
stephenplusplus merged 1 commit into
googleapis:masterfrom
stephenplusplus:spp--prediction
Dec 18, 2015
Merged

stephenplusplus merged 1 commit into
googleapis:masterfrom
stephenplusplus:spp--prediction

Conversation

@stephenplusplus

Copy link
Copy Markdown
Contributor

Fixes #976

Hello, world for Prediction API.

To Dos

  • Enable API for the Travis account
  • Add analyze method
  • Add to side navigation in docs
  • Docs
    • Show how to use a file when creating a model
    • Document/alias modelType to type when creating a model to distinguish between classification and regression
  • Tests
    • System
    • Unit
      • common/util
      • prediction/index
      • prediction/model

Preview

var gcloud = require('gcloud');

// Authenticating on a per-API-basis. You don't need to do this if you auth on a
// global basis (see Authentication section above).

var prediction = gcloud.prediction({
  projectId: 'my-project',
  keyFilename: '/path/to/keyfile.json'
});

// Get all of the trained models in your project.
prediction.getModels(function(err, models) {
  if (!err) {
    // `models` is an array of Model objects.
  }
});

// Reference an existing trained model.
var model = prediction.model('my-existing-model');

// Train a model.
model.train('english', 'Hello from your friends at Google!', function(err) {});

// Query a model.
model.query('Hello', function(err, results) {
  if (!err) {
    // results.winner == 'english'
    // results.scores == [
    //   {
    //     label: 'english',
    //     score: 1
    //   },
    //   {
    //     label: 'spanish',
    //     score: 0
    //   }
    // ]
  }
});

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 3, 2015
@stephenplusplus
stephenplusplus force-pushed the spp--prediction branch 6 times, most recently from d15dcbd to adf86db Compare December 4, 2015 19:12
@stephenplusplus

Copy link
Copy Markdown
Contributor Author

@jgeewax

@jgeewax

jgeewax commented Dec 8, 2015

Copy link
Copy Markdown
Contributor

Basic usage here LGTM. How about bulk-loading via the CSV trainedmodels.update method ? (https://cloud.google.com/prediction/docs/reference/v1.6/trainedmodels/update)

I'll ask someone from the Prediction team to take a look.

@stephenplusplus

Copy link
Copy Markdown
Contributor Author

I could be misunderstanding the API, but I think the only place it accepts a CSV file is when you create the model and point it to a GCS file (which is supported here):

prediction.createModel('new-model-name', {
  data: gcs.file('input-data.csv')
}, function() {});

For the update API, we have three ways of hitting that endpoint:

model.setMetadata({
  output: 'label',
  csvInstance: ['data']
}, function() {});
model.train('label', 'data', function() {});
var writeStream = model.createWriteStream('label');
writeStream.write('data');
// ... any number of writes
writeStream.end();

Added todos for better docs that show how to do these things

@stephenplusplus
stephenplusplus force-pushed the spp--prediction branch 4 times, most recently from 602a619 to a369d18 Compare December 9, 2015 20:14
@stephenplusplus

Copy link
Copy Markdown
Contributor Author

@callmehiphop feel free to pick this one apart now :)

@callmehiphop

Copy link
Copy Markdown
Contributor

Still reading through a lot of the documentation, but are we not providing support for hostedmodels?

Comment thread lib/prediction/model.js

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus

Copy link
Copy Markdown
Contributor Author

Changes made!

are we not providing support for hostedmodels?

I intended to originally. But when I read more about them, I found there are only 3, and they have a pretty serious limit:

Hosted models have a usage limit of 100 predictions/day/user across all demonstration models. Developers can set higher paid usage limits for models they create.

So, it sounded more like a "getting to know Prediction API" learning tool to me at this point. If and when it handles more queries, and the gallery grows larger, supporting this would be great.

@jgeewax any thoughts on supported hostedmodels?

@stephenplusplus

Copy link
Copy Markdown
Contributor Author

@jgeewax should we wait for a review from someone from the Prediction team?

⌚ This PR will self-merge in 24 hours

stephenplusplus added a commit that referenced this pull request Dec 18, 2015
@stephenplusplus
stephenplusplus merged commit 86883fa into googleapis:master Dec 18, 2015
miguelvelezsa pushed a commit that referenced this pull request Jul 23, 2025
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/74f0c42b-d8fe-4430-b878-ab099e9e7fe7/targets

- [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.)

Source-Link: googleapis/synthtool@e6f3d54
Source-Link: googleapis/synthtool@04573fd
sofisl pushed a commit that referenced this pull request Feb 3, 2026
…#989)

* docs(samples): add clustering & table ACL samples draft

* update createTableColumnACL

* docs(samples): add samples and tests

* fix incorrect file name

* rename region tag

* update samples

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* restore README

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix READMES

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
thiyaguk09 pushed a commit to thiyaguk09/google-cloud-node-fork that referenced this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants