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.5"
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.5"
38
const apiName = "prediction"
39
const apiVersion = "v1.5"
40
const basePath = "https://www.googleapis.com/prediction/v1.5/"
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.Trainedmodels = NewTrainedmodelsService(s)
69
BasePath string // API endpoint base URL
71
Hostedmodels *HostedmodelsService
73
Trainedmodels *TrainedmodelsService
76
func NewHostedmodelsService(s *Service) *HostedmodelsService {
77
rs := &HostedmodelsService{s: s}
81
type HostedmodelsService struct {
85
func NewTrainedmodelsService(s *Service) *TrainedmodelsService {
86
rs := &TrainedmodelsService{s: s}
90
type TrainedmodelsService struct {
95
// DataDescription: Description of the data the model was trained on.
96
DataDescription *AnalyzeDataDescription `json:"dataDescription,omitempty"`
98
// Errors: List of errors with the data.
99
Errors []map[string]string `json:"errors,omitempty"`
101
// Id: The unique name for the predictive model.
102
Id string `json:"id,omitempty"`
104
// Kind: What kind of resource this is.
105
Kind string `json:"kind,omitempty"`
107
// ModelDescription: Description of the model.
108
ModelDescription *AnalyzeModelDescription `json:"modelDescription,omitempty"`
110
// SelfLink: A URL to re-request this resource.
111
SelfLink string `json:"selfLink,omitempty"`
114
type AnalyzeDataDescription struct {
115
// Features: Description of the input features in the data set.
116
Features []*AnalyzeDataDescriptionFeatures `json:"features,omitempty"`
118
// OutputFeature: Description of the output value or label.
119
OutputFeature *AnalyzeDataDescriptionOutputFeature `json:"outputFeature,omitempty"`
122
type AnalyzeDataDescriptionFeatures struct {
123
// Categorical: Description of the categorical values of this feature.
124
Categorical *AnalyzeDataDescriptionFeaturesCategorical `json:"categorical,omitempty"`
126
// Index: The feature index.
127
Index int64 `json:"index,omitempty,string"`
129
// Numeric: Description of the numeric values of this feature.
130
Numeric *AnalyzeDataDescriptionFeaturesNumeric `json:"numeric,omitempty"`
132
// Text: Description of multiple-word text values of this feature.
133
Text *AnalyzeDataDescriptionFeaturesText `json:"text,omitempty"`
136
type AnalyzeDataDescriptionFeaturesCategorical struct {
137
// Count: Number of categorical values for this feature in the data.
138
Count int64 `json:"count,omitempty,string"`
140
// Values: List of all the categories for this feature in the data set.
141
Values []*AnalyzeDataDescriptionFeaturesCategoricalValues `json:"values,omitempty"`
144
type AnalyzeDataDescriptionFeaturesCategoricalValues struct {
145
// Count: Number of times this feature had this value.
146
Count int64 `json:"count,omitempty,string"`
148
// Value: The category name.
149
Value string `json:"value,omitempty"`
152
type AnalyzeDataDescriptionFeaturesNumeric struct {
153
// Count: Number of numeric values for this feature in the data set.
154
Count int64 `json:"count,omitempty,string"`
156
// Mean: Mean of the numeric values of this feature in the data set.
157
Mean float64 `json:"mean,omitempty"`
159
// Variance: Variance of the numeric values of this feature in the data
161
Variance float64 `json:"variance,omitempty"`
164
type AnalyzeDataDescriptionFeaturesText struct {
165
// Count: Number of multiple-word text values for this feature.
166
Count int64 `json:"count,omitempty,string"`
169
type AnalyzeDataDescriptionOutputFeature struct {
170
// Numeric: Description of the output values in the data set.
171
Numeric *AnalyzeDataDescriptionOutputFeatureNumeric `json:"numeric,omitempty"`
173
// Text: Description of the output labels in the data set.
174
Text []*AnalyzeDataDescriptionOutputFeatureText `json:"text,omitempty"`
177
type AnalyzeDataDescriptionOutputFeatureNumeric struct {
178
// Count: Number of numeric output values in the data set.
179
Count int64 `json:"count,omitempty,string"`
181
// Mean: Mean of the output values in the data set.
182
Mean float64 `json:"mean,omitempty"`
184
// Variance: Variance of the output values in the data set.
185
Variance float64 `json:"variance,omitempty"`
188
type AnalyzeDataDescriptionOutputFeatureText struct {
189
// Count: Number of times the output label occurred in the data set.
190
Count int64 `json:"count,omitempty,string"`
192
// Value: The output label.
193
Value string `json:"value,omitempty"`
196
type AnalyzeModelDescription struct {
197
// ConfusionMatrix: An output confusion matrix. This shows an estimate
198
// for how this model will do in predictions. This is first indexed by
199
// the true class label. For each true class label, this provides a pair
200
// {predicted_label, count}, where count is the estimated number of
201
// times the model will predict the predicted label given the true
202
// label. Will not output if more then 100 classes [Categorical models
204
ConfusionMatrix *AnalyzeModelDescriptionConfusionMatrix `json:"confusionMatrix,omitempty"`
206
// ConfusionMatrixRowTotals: A list of the confusion matrix row totals
207
ConfusionMatrixRowTotals *AnalyzeModelDescriptionConfusionMatrixRowTotals `json:"confusionMatrixRowTotals,omitempty"`
209
// Modelinfo: Basic information about the model.
210
Modelinfo *Training `json:"modelinfo,omitempty"`
213
type AnalyzeModelDescriptionConfusionMatrix struct {
216
type AnalyzeModelDescriptionConfusionMatrixRowTotals struct {
220
// Input: Input to the model for a prediction
221
Input *InputInput `json:"input,omitempty"`
224
type InputInput struct {
225
// CsvInstance: A list of input features, these can be strings or
227
CsvInstance []interface{} `json:"csvInstance,omitempty"`
231
// Items: List of models.
232
Items []*Training `json:"items,omitempty"`
234
// Kind: What kind of resource this is.
235
Kind string `json:"kind,omitempty"`
237
// NextPageToken: Pagination token to fetch the next page, if one
239
NextPageToken string `json:"nextPageToken,omitempty"`
241
// SelfLink: A URL to re-request this resource.
242
SelfLink string `json:"selfLink,omitempty"`
246
// Id: The unique name for the predictive model.
247
Id string `json:"id,omitempty"`
249
// Kind: What kind of resource this is.
250
Kind string `json:"kind,omitempty"`
252
// OutputLabel: The most likely class label [Categorical models only].
253
OutputLabel string `json:"outputLabel,omitempty"`
255
// OutputMulti: A list of class labels with their estimated
256
// probabilities [Categorical models only].
257
OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
259
// OutputValue: The estimated regression value [Regression models only].
260
OutputValue float64 `json:"outputValue,omitempty"`
262
// SelfLink: A URL to re-request this resource.
263
SelfLink string `json:"selfLink,omitempty"`
266
type OutputOutputMulti struct {
267
// Label: The class label.
268
Label string `json:"label,omitempty"`
270
// Score: The probability of the class label.
271
Score float64 `json:"score,omitempty"`
274
type Training struct {
275
// Created: Insert time of the model (as a RFC 3339 timestamp).
276
Created string `json:"created,omitempty"`
278
// Id: The unique name for the predictive model.
279
Id string `json:"id,omitempty"`
281
// Kind: What kind of resource this is.
282
Kind string `json:"kind,omitempty"`
284
// ModelInfo: Model metadata.
285
ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
287
// ModelType: Type of predictive model (classification or regression)
288
ModelType string `json:"modelType,omitempty"`
290
// SelfLink: A URL to re-request this resource.
291
SelfLink string `json:"selfLink,omitempty"`
293
// StorageDataLocation: Google storage location of the training data
295
StorageDataLocation string `json:"storageDataLocation,omitempty"`
297
// StoragePMMLLocation: Google storage location of the preprocessing
299
StoragePMMLLocation string `json:"storagePMMLLocation,omitempty"`
301
// StoragePMMLModelLocation: Google storage location of the pmml model
303
StoragePMMLModelLocation string `json:"storagePMMLModelLocation,omitempty"`
305
// TrainingComplete: Training completion time (as a RFC 3339 timestamp).
306
TrainingComplete string `json:"trainingComplete,omitempty"`
308
// TrainingInstances: Instances to train model on.
309
TrainingInstances []*TrainingTrainingInstances `json:"trainingInstances,omitempty"`
311
// TrainingStatus: The current status of the training job. This can be
312
// one of following: RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND
313
TrainingStatus string `json:"trainingStatus,omitempty"`
315
// Utility: A class weighting function, which allows the importance
316
// weights for class labels to be specified [Categorical models only].
317
Utility []*TrainingUtility `json:"utility,omitempty"`
320
type TrainingModelInfo struct {
321
// ClassWeightedAccuracy: Estimated accuracy of model taking utility
322
// weights into account [Categorical models only].
323
ClassWeightedAccuracy float64 `json:"classWeightedAccuracy,omitempty"`
325
// ClassificationAccuracy: A number between 0.0 and 1.0, where 1.0 is
326
// 100% accurate. This is an estimate, based on the amount and quality
327
// of the training data, of the estimated prediction accuracy. You can
328
// use this is a guide to decide whether the results are accurate enough
329
// for your needs. This estimate will be more reliable if your real
330
// input data is similar to your training data [Categorical models
332
ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
334
// MeanSquaredError: An estimated mean squared error. The can be used to
335
// measure the quality of the predicted model [Regression models only].
336
MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
338
// ModelType: Type of predictive model (CLASSIFICATION or REGRESSION)
339
ModelType string `json:"modelType,omitempty"`
341
// NumberInstances: Number of valid data instances used in the trained
343
NumberInstances int64 `json:"numberInstances,omitempty,string"`
345
// NumberLabels: Number of class labels in the trained model
346
// [Categorical models only].
347
NumberLabels int64 `json:"numberLabels,omitempty,string"`
350
type TrainingTrainingInstances struct {
351
// CsvInstance: The input features for this instance
352
CsvInstance []interface{} `json:"csvInstance,omitempty"`
354
// Output: The generic output value - could be regression or class label
355
Output string `json:"output,omitempty"`
358
type TrainingUtility struct {
362
// CsvInstance: The input features for this instance
363
CsvInstance []interface{} `json:"csvInstance,omitempty"`
365
// Label: The class label of this instance
366
Label string `json:"label,omitempty"`
368
// Output: The generic output value - could be regression value or class
370
Output string `json:"output,omitempty"`
373
// method id "prediction.hostedmodels.predict":
375
type HostedmodelsPredictCall struct {
377
hostedModelName string
379
opt_ map[string]interface{}
382
// Predict: Submit input and request an output against a hosted model.
383
func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
384
c := &HostedmodelsPredictCall{s: r.s, opt_: make(map[string]interface{})}
385
c.hostedModelName = hostedModelName
390
// Fields allows partial responses to be retrieved.
391
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
392
// for more information.
393
func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
394
c.opt_["fields"] = googleapi.CombineFields(s)
398
func (c *HostedmodelsPredictCall) Do() (*Output, error) {
399
var body io.Reader = nil
400
body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
404
ctype := "application/json"
405
params := make(url.Values)
406
params.Set("alt", "json")
407
if v, ok := c.opt_["fields"]; ok {
408
params.Set("fields", fmt.Sprintf("%v", v))
410
urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
411
urls += "?" + params.Encode()
412
req, _ := http.NewRequest("POST", urls, body)
413
googleapi.Expand(req.URL, map[string]string{
414
"hostedModelName": c.hostedModelName,
416
req.Header.Set("Content-Type", ctype)
417
req.Header.Set("User-Agent", "google-api-go-client/0.5")
418
res, err := c.s.client.Do(req)
422
defer googleapi.CloseBody(res)
423
if err := googleapi.CheckResponse(res); err != nil {
427
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
432
// "description": "Submit input and request an output against a hosted model.",
433
// "httpMethod": "POST",
434
// "id": "prediction.hostedmodels.predict",
435
// "parameterOrder": [
439
// "hostedModelName": {
440
// "description": "The name of a hosted model.",
441
// "location": "path",
446
// "path": "hostedmodels/{hostedModelName}/predict",
454
// "https://www.googleapis.com/auth/prediction"
460
// method id "prediction.trainedmodels.analyze":
462
type TrainedmodelsAnalyzeCall struct {
465
opt_ map[string]interface{}
468
// Analyze: Get analysis of the model and the data the model was trained
470
func (r *TrainedmodelsService) Analyze(id string) *TrainedmodelsAnalyzeCall {
471
c := &TrainedmodelsAnalyzeCall{s: r.s, opt_: make(map[string]interface{})}
476
// Fields allows partial responses to be retrieved.
477
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
478
// for more information.
479
func (c *TrainedmodelsAnalyzeCall) Fields(s ...googleapi.Field) *TrainedmodelsAnalyzeCall {
480
c.opt_["fields"] = googleapi.CombineFields(s)
484
func (c *TrainedmodelsAnalyzeCall) Do() (*Analyze, error) {
485
var body io.Reader = nil
486
params := make(url.Values)
487
params.Set("alt", "json")
488
if v, ok := c.opt_["fields"]; ok {
489
params.Set("fields", fmt.Sprintf("%v", v))
491
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/analyze")
492
urls += "?" + params.Encode()
493
req, _ := http.NewRequest("GET", urls, body)
494
googleapi.Expand(req.URL, map[string]string{
497
req.Header.Set("User-Agent", "google-api-go-client/0.5")
498
res, err := c.s.client.Do(req)
502
defer googleapi.CloseBody(res)
503
if err := googleapi.CheckResponse(res); err != nil {
507
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
512
// "description": "Get analysis of the model and the data the model was trained on.",
513
// "httpMethod": "GET",
514
// "id": "prediction.trainedmodels.analyze",
515
// "parameterOrder": [
520
// "description": "The unique name for the predictive model.",
521
// "location": "path",
526
// "path": "trainedmodels/{id}/analyze",
531
// "https://www.googleapis.com/auth/prediction"
537
// method id "prediction.trainedmodels.delete":
539
type TrainedmodelsDeleteCall struct {
542
opt_ map[string]interface{}
545
// Delete: Delete a trained model.
546
func (r *TrainedmodelsService) Delete(id string) *TrainedmodelsDeleteCall {
547
c := &TrainedmodelsDeleteCall{s: r.s, opt_: make(map[string]interface{})}
552
// Fields allows partial responses to be retrieved.
553
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
554
// for more information.
555
func (c *TrainedmodelsDeleteCall) Fields(s ...googleapi.Field) *TrainedmodelsDeleteCall {
556
c.opt_["fields"] = googleapi.CombineFields(s)
560
func (c *TrainedmodelsDeleteCall) Do() error {
561
var body io.Reader = nil
562
params := make(url.Values)
563
params.Set("alt", "json")
564
if v, ok := c.opt_["fields"]; ok {
565
params.Set("fields", fmt.Sprintf("%v", v))
567
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
568
urls += "?" + params.Encode()
569
req, _ := http.NewRequest("DELETE", urls, body)
570
googleapi.Expand(req.URL, map[string]string{
573
req.Header.Set("User-Agent", "google-api-go-client/0.5")
574
res, err := c.s.client.Do(req)
578
defer googleapi.CloseBody(res)
579
if err := googleapi.CheckResponse(res); err != nil {
584
// "description": "Delete a trained model.",
585
// "httpMethod": "DELETE",
586
// "id": "prediction.trainedmodels.delete",
587
// "parameterOrder": [
592
// "description": "The unique name for the predictive model.",
593
// "location": "path",
598
// "path": "trainedmodels/{id}",
600
// "https://www.googleapis.com/auth/prediction"
606
// method id "prediction.trainedmodels.get":
608
type TrainedmodelsGetCall struct {
611
opt_ map[string]interface{}
614
// Get: Check training status of your model.
615
func (r *TrainedmodelsService) Get(id string) *TrainedmodelsGetCall {
616
c := &TrainedmodelsGetCall{s: r.s, opt_: make(map[string]interface{})}
621
// Fields allows partial responses to be retrieved.
622
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
623
// for more information.
624
func (c *TrainedmodelsGetCall) Fields(s ...googleapi.Field) *TrainedmodelsGetCall {
625
c.opt_["fields"] = googleapi.CombineFields(s)
629
func (c *TrainedmodelsGetCall) Do() (*Training, error) {
630
var body io.Reader = nil
631
params := make(url.Values)
632
params.Set("alt", "json")
633
if v, ok := c.opt_["fields"]; ok {
634
params.Set("fields", fmt.Sprintf("%v", v))
636
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
637
urls += "?" + params.Encode()
638
req, _ := http.NewRequest("GET", urls, body)
639
googleapi.Expand(req.URL, map[string]string{
642
req.Header.Set("User-Agent", "google-api-go-client/0.5")
643
res, err := c.s.client.Do(req)
647
defer googleapi.CloseBody(res)
648
if err := googleapi.CheckResponse(res); err != nil {
652
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
657
// "description": "Check training status of your model.",
658
// "httpMethod": "GET",
659
// "id": "prediction.trainedmodels.get",
660
// "parameterOrder": [
665
// "description": "The unique name for the predictive model.",
666
// "location": "path",
671
// "path": "trainedmodels/{id}",
673
// "$ref": "Training"
676
// "https://www.googleapis.com/auth/prediction"
682
// method id "prediction.trainedmodels.insert":
684
type TrainedmodelsInsertCall struct {
687
opt_ map[string]interface{}
690
// Insert: Begin training your model.
691
func (r *TrainedmodelsService) Insert(training *Training) *TrainedmodelsInsertCall {
692
c := &TrainedmodelsInsertCall{s: r.s, opt_: make(map[string]interface{})}
693
c.training = training
697
// Fields allows partial responses to be retrieved.
698
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
699
// for more information.
700
func (c *TrainedmodelsInsertCall) Fields(s ...googleapi.Field) *TrainedmodelsInsertCall {
701
c.opt_["fields"] = googleapi.CombineFields(s)
705
func (c *TrainedmodelsInsertCall) Do() (*Training, error) {
706
var body io.Reader = nil
707
body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
711
ctype := "application/json"
712
params := make(url.Values)
713
params.Set("alt", "json")
714
if v, ok := c.opt_["fields"]; ok {
715
params.Set("fields", fmt.Sprintf("%v", v))
717
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels")
718
urls += "?" + params.Encode()
719
req, _ := http.NewRequest("POST", urls, body)
720
googleapi.SetOpaque(req.URL)
721
req.Header.Set("Content-Type", ctype)
722
req.Header.Set("User-Agent", "google-api-go-client/0.5")
723
res, err := c.s.client.Do(req)
727
defer googleapi.CloseBody(res)
728
if err := googleapi.CheckResponse(res); err != nil {
732
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
737
// "description": "Begin training your model.",
738
// "httpMethod": "POST",
739
// "id": "prediction.trainedmodels.insert",
740
// "path": "trainedmodels",
742
// "$ref": "Training"
745
// "$ref": "Training"
748
// "https://www.googleapis.com/auth/devstorage.full_control",
749
// "https://www.googleapis.com/auth/devstorage.read_only",
750
// "https://www.googleapis.com/auth/devstorage.read_write",
751
// "https://www.googleapis.com/auth/prediction"
757
// method id "prediction.trainedmodels.list":
759
type TrainedmodelsListCall struct {
761
opt_ map[string]interface{}
764
// List: List available models.
765
func (r *TrainedmodelsService) List() *TrainedmodelsListCall {
766
c := &TrainedmodelsListCall{s: r.s, opt_: make(map[string]interface{})}
770
// MaxResults sets the optional parameter "maxResults": Maximum number
771
// of results to return
772
func (c *TrainedmodelsListCall) MaxResults(maxResults int64) *TrainedmodelsListCall {
773
c.opt_["maxResults"] = maxResults
777
// PageToken sets the optional parameter "pageToken": Pagination token
778
func (c *TrainedmodelsListCall) PageToken(pageToken string) *TrainedmodelsListCall {
779
c.opt_["pageToken"] = pageToken
783
// Fields allows partial responses to be retrieved.
784
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
785
// for more information.
786
func (c *TrainedmodelsListCall) Fields(s ...googleapi.Field) *TrainedmodelsListCall {
787
c.opt_["fields"] = googleapi.CombineFields(s)
791
func (c *TrainedmodelsListCall) Do() (*List, error) {
792
var body io.Reader = nil
793
params := make(url.Values)
794
params.Set("alt", "json")
795
if v, ok := c.opt_["maxResults"]; ok {
796
params.Set("maxResults", fmt.Sprintf("%v", v))
798
if v, ok := c.opt_["pageToken"]; ok {
799
params.Set("pageToken", fmt.Sprintf("%v", v))
801
if v, ok := c.opt_["fields"]; ok {
802
params.Set("fields", fmt.Sprintf("%v", v))
804
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/list")
805
urls += "?" + params.Encode()
806
req, _ := http.NewRequest("GET", urls, body)
807
googleapi.SetOpaque(req.URL)
808
req.Header.Set("User-Agent", "google-api-go-client/0.5")
809
res, err := c.s.client.Do(req)
813
defer googleapi.CloseBody(res)
814
if err := googleapi.CheckResponse(res); err != nil {
818
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
823
// "description": "List available models.",
824
// "httpMethod": "GET",
825
// "id": "prediction.trainedmodels.list",
828
// "description": "Maximum number of results to return",
829
// "format": "uint32",
830
// "location": "query",
835
// "description": "Pagination token",
836
// "location": "query",
840
// "path": "trainedmodels/list",
845
// "https://www.googleapis.com/auth/prediction"
851
// method id "prediction.trainedmodels.predict":
853
type TrainedmodelsPredictCall struct {
857
opt_ map[string]interface{}
860
// Predict: Submit model id and request a prediction.
861
func (r *TrainedmodelsService) Predict(id string, input *Input) *TrainedmodelsPredictCall {
862
c := &TrainedmodelsPredictCall{s: r.s, opt_: make(map[string]interface{})}
868
// Fields allows partial responses to be retrieved.
869
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
870
// for more information.
871
func (c *TrainedmodelsPredictCall) Fields(s ...googleapi.Field) *TrainedmodelsPredictCall {
872
c.opt_["fields"] = googleapi.CombineFields(s)
876
func (c *TrainedmodelsPredictCall) Do() (*Output, error) {
877
var body io.Reader = nil
878
body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
882
ctype := "application/json"
883
params := make(url.Values)
884
params.Set("alt", "json")
885
if v, ok := c.opt_["fields"]; ok {
886
params.Set("fields", fmt.Sprintf("%v", v))
888
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/predict")
889
urls += "?" + params.Encode()
890
req, _ := http.NewRequest("POST", urls, body)
891
googleapi.Expand(req.URL, map[string]string{
894
req.Header.Set("Content-Type", ctype)
895
req.Header.Set("User-Agent", "google-api-go-client/0.5")
896
res, err := c.s.client.Do(req)
900
defer googleapi.CloseBody(res)
901
if err := googleapi.CheckResponse(res); err != nil {
905
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
910
// "description": "Submit model id and request a prediction.",
911
// "httpMethod": "POST",
912
// "id": "prediction.trainedmodels.predict",
913
// "parameterOrder": [
918
// "description": "The unique name for the predictive model.",
919
// "location": "path",
924
// "path": "trainedmodels/{id}/predict",
932
// "https://www.googleapis.com/auth/prediction"
938
// method id "prediction.trainedmodels.update":
940
type TrainedmodelsUpdateCall struct {
944
opt_ map[string]interface{}
947
// Update: Add new data to a trained model.
948
func (r *TrainedmodelsService) Update(id string, update *Update) *TrainedmodelsUpdateCall {
949
c := &TrainedmodelsUpdateCall{s: r.s, opt_: make(map[string]interface{})}
955
// Fields allows partial responses to be retrieved.
956
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
957
// for more information.
958
func (c *TrainedmodelsUpdateCall) Fields(s ...googleapi.Field) *TrainedmodelsUpdateCall {
959
c.opt_["fields"] = googleapi.CombineFields(s)
963
func (c *TrainedmodelsUpdateCall) Do() (*Training, error) {
964
var body io.Reader = nil
965
body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
969
ctype := "application/json"
970
params := make(url.Values)
971
params.Set("alt", "json")
972
if v, ok := c.opt_["fields"]; ok {
973
params.Set("fields", fmt.Sprintf("%v", v))
975
urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
976
urls += "?" + params.Encode()
977
req, _ := http.NewRequest("PUT", urls, body)
978
googleapi.Expand(req.URL, map[string]string{
981
req.Header.Set("Content-Type", ctype)
982
req.Header.Set("User-Agent", "google-api-go-client/0.5")
983
res, err := c.s.client.Do(req)
987
defer googleapi.CloseBody(res)
988
if err := googleapi.CheckResponse(res); err != nil {
992
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
997
// "description": "Add new data to a trained model.",
998
// "httpMethod": "PUT",
999
// "id": "prediction.trainedmodels.update",
1000
// "parameterOrder": [
1005
// "description": "The unique name for the predictive model.",
1006
// "location": "path",
1007
// "required": true,
1011
// "path": "trainedmodels/{id}",
1016
// "$ref": "Training"
1019
// "https://www.googleapis.com/auth/prediction"