1
// Package prediction provides access to the Prediction API.
3
// See https://developers.google.com/prediction/docs/developer-guide
7
// import "google.golang.org/api/prediction/v1.2"
9
// predictionService, err := prediction.New(oauthHttpClient)
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "prediction:v1.2"
38
const apiName = "prediction"
39
const apiVersion = "v1.2"
40
const basePath = "https://www.googleapis.com/prediction/v1.2/"
42
// OAuth2 scopes used by this API.
44
// Manage your data and permissions in Google Cloud Storage
45
DevstorageFull_controlScope = "https://www.googleapis.com/auth/devstorage.full_control"
47
// View your data in Google Cloud Storage
48
DevstorageRead_onlyScope = "https://www.googleapis.com/auth/devstorage.read_only"
50
// Manage your data in Google Cloud Storage
51
DevstorageRead_writeScope = "https://www.googleapis.com/auth/devstorage.read_write"
53
// Manage your data in the Google Prediction API
54
PredictionScope = "https://www.googleapis.com/auth/prediction"
57
func New(client *http.Client) (*Service, error) {
59
return nil, errors.New("client is nil")
61
s := &Service{client: client, BasePath: basePath}
62
s.Hostedmodels = NewHostedmodelsService(s)
63
s.Training = NewTrainingService(s)
69
BasePath string // API endpoint base URL
71
Hostedmodels *HostedmodelsService
73
Training *TrainingService
76
func NewHostedmodelsService(s *Service) *HostedmodelsService {
77
rs := &HostedmodelsService{s: s}
81
type HostedmodelsService struct {
85
func NewTrainingService(s *Service) *TrainingService {
86
rs := &TrainingService{s: s}
90
type TrainingService struct {
95
Input *InputInput `json:"input,omitempty"`
98
type InputInput struct {
99
CsvInstance []interface{} `json:"csvInstance,omitempty"`
103
Id string `json:"id,omitempty"`
105
Kind string `json:"kind,omitempty"`
107
OutputLabel string `json:"outputLabel,omitempty"`
109
OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
111
OutputValue float64 `json:"outputValue,omitempty"`
113
SelfLink string `json:"selfLink,omitempty"`
116
type OutputOutputMulti struct {
117
Label string `json:"label,omitempty"`
119
Score float64 `json:"score,omitempty"`
122
type Training struct {
123
Id string `json:"id,omitempty"`
125
Kind string `json:"kind,omitempty"`
127
ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
129
SelfLink string `json:"selfLink,omitempty"`
131
TrainingStatus string `json:"trainingStatus,omitempty"`
134
type TrainingModelInfo struct {
135
ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
137
MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
139
ModelType string `json:"modelType,omitempty"`
143
// ClassLabel: The true class label of this instance
144
ClassLabel string `json:"classLabel,omitempty"`
146
// CsvInstance: The input features for this instance
147
CsvInstance []interface{} `json:"csvInstance,omitempty"`
150
// method id "prediction.predict":
152
type PredictCall struct {
156
opt_ map[string]interface{}
159
// Predict: Submit data and request a prediction
160
func (s *Service) Predict(data string, input *Input) *PredictCall {
161
c := &PredictCall{s: s, opt_: make(map[string]interface{})}
167
// Fields allows partial responses to be retrieved.
168
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
169
// for more information.
170
func (c *PredictCall) Fields(s ...googleapi.Field) *PredictCall {
171
c.opt_["fields"] = googleapi.CombineFields(s)
175
func (c *PredictCall) Do() (*Output, error) {
176
var body io.Reader = nil
177
body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
181
ctype := "application/json"
182
params := make(url.Values)
183
params.Set("alt", "json")
184
if v, ok := c.opt_["fields"]; ok {
185
params.Set("fields", fmt.Sprintf("%v", v))
187
urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}/predict")
188
urls += "?" + params.Encode()
189
req, _ := http.NewRequest("POST", urls, body)
190
googleapi.Expand(req.URL, map[string]string{
193
req.Header.Set("Content-Type", ctype)
194
req.Header.Set("User-Agent", "google-api-go-client/0.5")
195
res, err := c.s.client.Do(req)
199
defer googleapi.CloseBody(res)
200
if err := googleapi.CheckResponse(res); err != nil {
204
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
209
// "description": "Submit data and request a prediction",
210
// "httpMethod": "POST",
211
// "id": "prediction.predict",
212
// "parameterOrder": [
217
// "description": "mybucket%2Fmydata resource in Google Storage",
218
// "location": "path",
223
// "path": "training/{data}/predict",
231
// "https://www.googleapis.com/auth/prediction"
237
// method id "prediction.hostedmodels.predict":
239
type HostedmodelsPredictCall struct {
241
hostedModelName string
243
opt_ map[string]interface{}
246
// Predict: Submit input and request an output against a hosted model
247
func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
248
c := &HostedmodelsPredictCall{s: r.s, opt_: make(map[string]interface{})}
249
c.hostedModelName = hostedModelName
254
// Fields allows partial responses to be retrieved.
255
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
256
// for more information.
257
func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
258
c.opt_["fields"] = googleapi.CombineFields(s)
262
func (c *HostedmodelsPredictCall) Do() (*Output, error) {
263
var body io.Reader = nil
264
body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
268
ctype := "application/json"
269
params := make(url.Values)
270
params.Set("alt", "json")
271
if v, ok := c.opt_["fields"]; ok {
272
params.Set("fields", fmt.Sprintf("%v", v))
274
urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
275
urls += "?" + params.Encode()
276
req, _ := http.NewRequest("POST", urls, body)
277
googleapi.Expand(req.URL, map[string]string{
278
"hostedModelName": c.hostedModelName,
280
req.Header.Set("Content-Type", ctype)
281
req.Header.Set("User-Agent", "google-api-go-client/0.5")
282
res, err := c.s.client.Do(req)
286
defer googleapi.CloseBody(res)
287
if err := googleapi.CheckResponse(res); err != nil {
291
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
296
// "description": "Submit input and request an output against a hosted model",
297
// "httpMethod": "POST",
298
// "id": "prediction.hostedmodels.predict",
299
// "parameterOrder": [
303
// "hostedModelName": {
304
// "description": "The name of a hosted model",
305
// "location": "path",
310
// "path": "hostedmodels/{hostedModelName}/predict",
318
// "https://www.googleapis.com/auth/prediction"
324
// method id "prediction.training.delete":
326
type TrainingDeleteCall struct {
329
opt_ map[string]interface{}
332
// Delete: Delete a trained model
333
func (r *TrainingService) Delete(data string) *TrainingDeleteCall {
334
c := &TrainingDeleteCall{s: r.s, opt_: make(map[string]interface{})}
339
// Fields allows partial responses to be retrieved.
340
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
341
// for more information.
342
func (c *TrainingDeleteCall) Fields(s ...googleapi.Field) *TrainingDeleteCall {
343
c.opt_["fields"] = googleapi.CombineFields(s)
347
func (c *TrainingDeleteCall) Do() error {
348
var body io.Reader = nil
349
params := make(url.Values)
350
params.Set("alt", "json")
351
if v, ok := c.opt_["fields"]; ok {
352
params.Set("fields", fmt.Sprintf("%v", v))
354
urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
355
urls += "?" + params.Encode()
356
req, _ := http.NewRequest("DELETE", urls, body)
357
googleapi.Expand(req.URL, map[string]string{
360
req.Header.Set("User-Agent", "google-api-go-client/0.5")
361
res, err := c.s.client.Do(req)
365
defer googleapi.CloseBody(res)
366
if err := googleapi.CheckResponse(res); err != nil {
371
// "description": "Delete a trained model",
372
// "httpMethod": "DELETE",
373
// "id": "prediction.training.delete",
374
// "parameterOrder": [
379
// "description": "mybucket/mydata resource in Google Storage",
380
// "location": "path",
385
// "path": "training/{data}",
387
// "https://www.googleapis.com/auth/prediction"
393
// method id "prediction.training.get":
395
type TrainingGetCall struct {
398
opt_ map[string]interface{}
401
// Get: Check training status of your model
402
func (r *TrainingService) Get(data string) *TrainingGetCall {
403
c := &TrainingGetCall{s: r.s, opt_: make(map[string]interface{})}
408
// Fields allows partial responses to be retrieved.
409
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
410
// for more information.
411
func (c *TrainingGetCall) Fields(s ...googleapi.Field) *TrainingGetCall {
412
c.opt_["fields"] = googleapi.CombineFields(s)
416
func (c *TrainingGetCall) Do() (*Training, error) {
417
var body io.Reader = nil
418
params := make(url.Values)
419
params.Set("alt", "json")
420
if v, ok := c.opt_["fields"]; ok {
421
params.Set("fields", fmt.Sprintf("%v", v))
423
urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
424
urls += "?" + params.Encode()
425
req, _ := http.NewRequest("GET", urls, body)
426
googleapi.Expand(req.URL, map[string]string{
429
req.Header.Set("User-Agent", "google-api-go-client/0.5")
430
res, err := c.s.client.Do(req)
434
defer googleapi.CloseBody(res)
435
if err := googleapi.CheckResponse(res); err != nil {
439
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
444
// "description": "Check training status of your model",
445
// "httpMethod": "GET",
446
// "id": "prediction.training.get",
447
// "parameterOrder": [
452
// "description": "mybucket/mydata resource in Google Storage",
453
// "location": "path",
458
// "path": "training/{data}",
460
// "$ref": "Training"
463
// "https://www.googleapis.com/auth/prediction"
469
// method id "prediction.training.insert":
471
type TrainingInsertCall struct {
474
opt_ map[string]interface{}
477
// Insert: Begin training your model
478
func (r *TrainingService) Insert(training *Training) *TrainingInsertCall {
479
c := &TrainingInsertCall{s: r.s, opt_: make(map[string]interface{})}
480
c.training = training
484
// Data sets the optional parameter "data": mybucket/mydata resource in
486
func (c *TrainingInsertCall) Data(data string) *TrainingInsertCall {
487
c.opt_["data"] = data
491
// Fields allows partial responses to be retrieved.
492
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
493
// for more information.
494
func (c *TrainingInsertCall) Fields(s ...googleapi.Field) *TrainingInsertCall {
495
c.opt_["fields"] = googleapi.CombineFields(s)
499
func (c *TrainingInsertCall) Do() (*Training, error) {
500
var body io.Reader = nil
501
body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
505
ctype := "application/json"
506
params := make(url.Values)
507
params.Set("alt", "json")
508
if v, ok := c.opt_["data"]; ok {
509
params.Set("data", fmt.Sprintf("%v", v))
511
if v, ok := c.opt_["fields"]; ok {
512
params.Set("fields", fmt.Sprintf("%v", v))
514
urls := googleapi.ResolveRelative(c.s.BasePath, "training")
515
urls += "?" + params.Encode()
516
req, _ := http.NewRequest("POST", urls, body)
517
googleapi.SetOpaque(req.URL)
518
req.Header.Set("Content-Type", ctype)
519
req.Header.Set("User-Agent", "google-api-go-client/0.5")
520
res, err := c.s.client.Do(req)
524
defer googleapi.CloseBody(res)
525
if err := googleapi.CheckResponse(res); err != nil {
529
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
534
// "description": "Begin training your model",
535
// "httpMethod": "POST",
536
// "id": "prediction.training.insert",
539
// "description": "mybucket/mydata resource in Google Storage",
540
// "location": "query",
544
// "path": "training",
546
// "$ref": "Training"
549
// "$ref": "Training"
552
// "https://www.googleapis.com/auth/devstorage.full_control",
553
// "https://www.googleapis.com/auth/devstorage.read_only",
554
// "https://www.googleapis.com/auth/devstorage.read_write",
555
// "https://www.googleapis.com/auth/prediction"
561
// method id "prediction.training.update":
563
type TrainingUpdateCall struct {
567
opt_ map[string]interface{}
570
// Update: Add new data to a trained model
571
func (r *TrainingService) Update(data string, update *Update) *TrainingUpdateCall {
572
c := &TrainingUpdateCall{s: r.s, opt_: make(map[string]interface{})}
578
// Fields allows partial responses to be retrieved.
579
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
580
// for more information.
581
func (c *TrainingUpdateCall) Fields(s ...googleapi.Field) *TrainingUpdateCall {
582
c.opt_["fields"] = googleapi.CombineFields(s)
586
func (c *TrainingUpdateCall) Do() (*Training, error) {
587
var body io.Reader = nil
588
body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
592
ctype := "application/json"
593
params := make(url.Values)
594
params.Set("alt", "json")
595
if v, ok := c.opt_["fields"]; ok {
596
params.Set("fields", fmt.Sprintf("%v", v))
598
urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
599
urls += "?" + params.Encode()
600
req, _ := http.NewRequest("PUT", urls, body)
601
googleapi.Expand(req.URL, map[string]string{
604
req.Header.Set("Content-Type", ctype)
605
req.Header.Set("User-Agent", "google-api-go-client/0.5")
606
res, err := c.s.client.Do(req)
610
defer googleapi.CloseBody(res)
611
if err := googleapi.CheckResponse(res); err != nil {
615
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
620
// "description": "Add new data to a trained model",
621
// "httpMethod": "PUT",
622
// "id": "prediction.training.update",
623
// "parameterOrder": [
628
// "description": "mybucket/mydata resource in Google Storage",
629
// "location": "path",
634
// "path": "training/{data}",
639
// "$ref": "Training"
642
// "https://www.googleapis.com/auth/prediction"