prediction-gen.go 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668
  1. // Package prediction provides access to the Prediction API.
  2. //
  3. // See https://developers.google.com/prediction/docs/developer-guide
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/prediction/v1.5"
  8. // ...
  9. // predictionService, err := prediction.New(oauthHttpClient)
  10. package prediction // import "google.golang.org/api/prediction/v1.5"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "prediction:v1.5"
  41. const apiName = "prediction"
  42. const apiVersion = "v1.5"
  43. const basePath = "https://www.googleapis.com/prediction/v1.5/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Manage your data and permissions in Google Cloud Storage
  47. DevstorageFullControlScope = "https://www.googleapis.com/auth/devstorage.full_control"
  48. // View your data in Google Cloud Storage
  49. DevstorageReadOnlyScope = "https://www.googleapis.com/auth/devstorage.read_only"
  50. // Manage your data in Google Cloud Storage
  51. DevstorageReadWriteScope = "https://www.googleapis.com/auth/devstorage.read_write"
  52. // Manage your data in the Google Prediction API
  53. PredictionScope = "https://www.googleapis.com/auth/prediction"
  54. )
  55. func New(client *http.Client) (*Service, error) {
  56. if client == nil {
  57. return nil, errors.New("client is nil")
  58. }
  59. s := &Service{client: client, BasePath: basePath}
  60. s.Hostedmodels = NewHostedmodelsService(s)
  61. s.Trainedmodels = NewTrainedmodelsService(s)
  62. return s, nil
  63. }
  64. type Service struct {
  65. client *http.Client
  66. BasePath string // API endpoint base URL
  67. UserAgent string // optional additional User-Agent fragment
  68. Hostedmodels *HostedmodelsService
  69. Trainedmodels *TrainedmodelsService
  70. }
  71. func (s *Service) userAgent() string {
  72. if s.UserAgent == "" {
  73. return googleapi.UserAgent
  74. }
  75. return googleapi.UserAgent + " " + s.UserAgent
  76. }
  77. func NewHostedmodelsService(s *Service) *HostedmodelsService {
  78. rs := &HostedmodelsService{s: s}
  79. return rs
  80. }
  81. type HostedmodelsService struct {
  82. s *Service
  83. }
  84. func NewTrainedmodelsService(s *Service) *TrainedmodelsService {
  85. rs := &TrainedmodelsService{s: s}
  86. return rs
  87. }
  88. type TrainedmodelsService struct {
  89. s *Service
  90. }
  91. type Analyze struct {
  92. // DataDescription: Description of the data the model was trained on.
  93. DataDescription *AnalyzeDataDescription `json:"dataDescription,omitempty"`
  94. // Errors: List of errors with the data.
  95. Errors []map[string]string `json:"errors,omitempty"`
  96. // Id: The unique name for the predictive model.
  97. Id string `json:"id,omitempty"`
  98. // Kind: What kind of resource this is.
  99. Kind string `json:"kind,omitempty"`
  100. // ModelDescription: Description of the model.
  101. ModelDescription *AnalyzeModelDescription `json:"modelDescription,omitempty"`
  102. // SelfLink: A URL to re-request this resource.
  103. SelfLink string `json:"selfLink,omitempty"`
  104. // ServerResponse contains the HTTP response code and headers from the
  105. // server.
  106. googleapi.ServerResponse `json:"-"`
  107. // ForceSendFields is a list of field names (e.g. "DataDescription") to
  108. // unconditionally include in API requests. By default, fields with
  109. // empty values are omitted from API requests. However, any non-pointer,
  110. // non-interface field appearing in ForceSendFields will be sent to the
  111. // server regardless of whether the field is empty or not. This may be
  112. // used to include empty fields in Patch requests.
  113. ForceSendFields []string `json:"-"`
  114. }
  115. func (s *Analyze) MarshalJSON() ([]byte, error) {
  116. type noMethod Analyze
  117. raw := noMethod(*s)
  118. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  119. }
  120. // AnalyzeDataDescription: Description of the data the model was trained
  121. // on.
  122. type AnalyzeDataDescription struct {
  123. // Features: Description of the input features in the data set.
  124. Features []*AnalyzeDataDescriptionFeatures `json:"features,omitempty"`
  125. // OutputFeature: Description of the output value or label.
  126. OutputFeature *AnalyzeDataDescriptionOutputFeature `json:"outputFeature,omitempty"`
  127. // ForceSendFields is a list of field names (e.g. "Features") to
  128. // unconditionally include in API requests. By default, fields with
  129. // empty values are omitted from API requests. However, any non-pointer,
  130. // non-interface field appearing in ForceSendFields will be sent to the
  131. // server regardless of whether the field is empty or not. This may be
  132. // used to include empty fields in Patch requests.
  133. ForceSendFields []string `json:"-"`
  134. }
  135. func (s *AnalyzeDataDescription) MarshalJSON() ([]byte, error) {
  136. type noMethod AnalyzeDataDescription
  137. raw := noMethod(*s)
  138. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  139. }
  140. type AnalyzeDataDescriptionFeatures struct {
  141. // Categorical: Description of the categorical values of this feature.
  142. Categorical *AnalyzeDataDescriptionFeaturesCategorical `json:"categorical,omitempty"`
  143. // Index: The feature index.
  144. Index int64 `json:"index,omitempty,string"`
  145. // Numeric: Description of the numeric values of this feature.
  146. Numeric *AnalyzeDataDescriptionFeaturesNumeric `json:"numeric,omitempty"`
  147. // Text: Description of multiple-word text values of this feature.
  148. Text *AnalyzeDataDescriptionFeaturesText `json:"text,omitempty"`
  149. // ForceSendFields is a list of field names (e.g. "Categorical") to
  150. // unconditionally include in API requests. By default, fields with
  151. // empty values are omitted from API requests. However, any non-pointer,
  152. // non-interface field appearing in ForceSendFields will be sent to the
  153. // server regardless of whether the field is empty or not. This may be
  154. // used to include empty fields in Patch requests.
  155. ForceSendFields []string `json:"-"`
  156. }
  157. func (s *AnalyzeDataDescriptionFeatures) MarshalJSON() ([]byte, error) {
  158. type noMethod AnalyzeDataDescriptionFeatures
  159. raw := noMethod(*s)
  160. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  161. }
  162. // AnalyzeDataDescriptionFeaturesCategorical: Description of the
  163. // categorical values of this feature.
  164. type AnalyzeDataDescriptionFeaturesCategorical struct {
  165. // Count: Number of categorical values for this feature in the data.
  166. Count int64 `json:"count,omitempty,string"`
  167. // Values: List of all the categories for this feature in the data set.
  168. Values []*AnalyzeDataDescriptionFeaturesCategoricalValues `json:"values,omitempty"`
  169. // ForceSendFields is a list of field names (e.g. "Count") to
  170. // unconditionally include in API requests. By default, fields with
  171. // empty values are omitted from API requests. However, any non-pointer,
  172. // non-interface field appearing in ForceSendFields will be sent to the
  173. // server regardless of whether the field is empty or not. This may be
  174. // used to include empty fields in Patch requests.
  175. ForceSendFields []string `json:"-"`
  176. }
  177. func (s *AnalyzeDataDescriptionFeaturesCategorical) MarshalJSON() ([]byte, error) {
  178. type noMethod AnalyzeDataDescriptionFeaturesCategorical
  179. raw := noMethod(*s)
  180. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  181. }
  182. type AnalyzeDataDescriptionFeaturesCategoricalValues struct {
  183. // Count: Number of times this feature had this value.
  184. Count int64 `json:"count,omitempty,string"`
  185. // Value: The category name.
  186. Value string `json:"value,omitempty"`
  187. // ForceSendFields is a list of field names (e.g. "Count") to
  188. // unconditionally include in API requests. By default, fields with
  189. // empty values are omitted from API requests. However, any non-pointer,
  190. // non-interface field appearing in ForceSendFields will be sent to the
  191. // server regardless of whether the field is empty or not. This may be
  192. // used to include empty fields in Patch requests.
  193. ForceSendFields []string `json:"-"`
  194. }
  195. func (s *AnalyzeDataDescriptionFeaturesCategoricalValues) MarshalJSON() ([]byte, error) {
  196. type noMethod AnalyzeDataDescriptionFeaturesCategoricalValues
  197. raw := noMethod(*s)
  198. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  199. }
  200. // AnalyzeDataDescriptionFeaturesNumeric: Description of the numeric
  201. // values of this feature.
  202. type AnalyzeDataDescriptionFeaturesNumeric struct {
  203. // Count: Number of numeric values for this feature in the data set.
  204. Count int64 `json:"count,omitempty,string"`
  205. // Mean: Mean of the numeric values of this feature in the data set.
  206. Mean float64 `json:"mean,omitempty"`
  207. // Variance: Variance of the numeric values of this feature in the data
  208. // set.
  209. Variance float64 `json:"variance,omitempty"`
  210. // ForceSendFields is a list of field names (e.g. "Count") to
  211. // unconditionally include in API requests. By default, fields with
  212. // empty values are omitted from API requests. However, any non-pointer,
  213. // non-interface field appearing in ForceSendFields will be sent to the
  214. // server regardless of whether the field is empty or not. This may be
  215. // used to include empty fields in Patch requests.
  216. ForceSendFields []string `json:"-"`
  217. }
  218. func (s *AnalyzeDataDescriptionFeaturesNumeric) MarshalJSON() ([]byte, error) {
  219. type noMethod AnalyzeDataDescriptionFeaturesNumeric
  220. raw := noMethod(*s)
  221. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  222. }
  223. // AnalyzeDataDescriptionFeaturesText: Description of multiple-word text
  224. // values of this feature.
  225. type AnalyzeDataDescriptionFeaturesText struct {
  226. // Count: Number of multiple-word text values for this feature.
  227. Count int64 `json:"count,omitempty,string"`
  228. // ForceSendFields is a list of field names (e.g. "Count") to
  229. // unconditionally include in API requests. By default, fields with
  230. // empty values are omitted from API requests. However, any non-pointer,
  231. // non-interface field appearing in ForceSendFields will be sent to the
  232. // server regardless of whether the field is empty or not. This may be
  233. // used to include empty fields in Patch requests.
  234. ForceSendFields []string `json:"-"`
  235. }
  236. func (s *AnalyzeDataDescriptionFeaturesText) MarshalJSON() ([]byte, error) {
  237. type noMethod AnalyzeDataDescriptionFeaturesText
  238. raw := noMethod(*s)
  239. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  240. }
  241. // AnalyzeDataDescriptionOutputFeature: Description of the output value
  242. // or label.
  243. type AnalyzeDataDescriptionOutputFeature struct {
  244. // Numeric: Description of the output values in the data set.
  245. Numeric *AnalyzeDataDescriptionOutputFeatureNumeric `json:"numeric,omitempty"`
  246. // Text: Description of the output labels in the data set.
  247. Text []*AnalyzeDataDescriptionOutputFeatureText `json:"text,omitempty"`
  248. // ForceSendFields is a list of field names (e.g. "Numeric") to
  249. // unconditionally include in API requests. By default, fields with
  250. // empty values are omitted from API requests. However, any non-pointer,
  251. // non-interface field appearing in ForceSendFields will be sent to the
  252. // server regardless of whether the field is empty or not. This may be
  253. // used to include empty fields in Patch requests.
  254. ForceSendFields []string `json:"-"`
  255. }
  256. func (s *AnalyzeDataDescriptionOutputFeature) MarshalJSON() ([]byte, error) {
  257. type noMethod AnalyzeDataDescriptionOutputFeature
  258. raw := noMethod(*s)
  259. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  260. }
  261. // AnalyzeDataDescriptionOutputFeatureNumeric: Description of the output
  262. // values in the data set.
  263. type AnalyzeDataDescriptionOutputFeatureNumeric struct {
  264. // Count: Number of numeric output values in the data set.
  265. Count int64 `json:"count,omitempty,string"`
  266. // Mean: Mean of the output values in the data set.
  267. Mean float64 `json:"mean,omitempty"`
  268. // Variance: Variance of the output values in the data set.
  269. Variance float64 `json:"variance,omitempty"`
  270. // ForceSendFields is a list of field names (e.g. "Count") to
  271. // unconditionally include in API requests. By default, fields with
  272. // empty values are omitted from API requests. However, any non-pointer,
  273. // non-interface field appearing in ForceSendFields will be sent to the
  274. // server regardless of whether the field is empty or not. This may be
  275. // used to include empty fields in Patch requests.
  276. ForceSendFields []string `json:"-"`
  277. }
  278. func (s *AnalyzeDataDescriptionOutputFeatureNumeric) MarshalJSON() ([]byte, error) {
  279. type noMethod AnalyzeDataDescriptionOutputFeatureNumeric
  280. raw := noMethod(*s)
  281. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  282. }
  283. type AnalyzeDataDescriptionOutputFeatureText struct {
  284. // Count: Number of times the output label occurred in the data set.
  285. Count int64 `json:"count,omitempty,string"`
  286. // Value: The output label.
  287. Value string `json:"value,omitempty"`
  288. // ForceSendFields is a list of field names (e.g. "Count") to
  289. // unconditionally include in API requests. By default, fields with
  290. // empty values are omitted from API requests. However, any non-pointer,
  291. // non-interface field appearing in ForceSendFields will be sent to the
  292. // server regardless of whether the field is empty or not. This may be
  293. // used to include empty fields in Patch requests.
  294. ForceSendFields []string `json:"-"`
  295. }
  296. func (s *AnalyzeDataDescriptionOutputFeatureText) MarshalJSON() ([]byte, error) {
  297. type noMethod AnalyzeDataDescriptionOutputFeatureText
  298. raw := noMethod(*s)
  299. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  300. }
  301. // AnalyzeModelDescription: Description of the model.
  302. type AnalyzeModelDescription struct {
  303. // ConfusionMatrix: An output confusion matrix. This shows an estimate
  304. // for how this model will do in predictions. This is first indexed by
  305. // the true class label. For each true class label, this provides a pair
  306. // {predicted_label, count}, where count is the estimated number of
  307. // times the model will predict the predicted label given the true
  308. // label. Will not output if more then 100 classes [Categorical models
  309. // only].
  310. ConfusionMatrix *AnalyzeModelDescriptionConfusionMatrix `json:"confusionMatrix,omitempty"`
  311. // ConfusionMatrixRowTotals: A list of the confusion matrix row totals
  312. ConfusionMatrixRowTotals *AnalyzeModelDescriptionConfusionMatrixRowTotals `json:"confusionMatrixRowTotals,omitempty"`
  313. // Modelinfo: Basic information about the model.
  314. Modelinfo *Training `json:"modelinfo,omitempty"`
  315. // ForceSendFields is a list of field names (e.g. "ConfusionMatrix") to
  316. // unconditionally include in API requests. By default, fields with
  317. // empty values are omitted from API requests. However, any non-pointer,
  318. // non-interface field appearing in ForceSendFields will be sent to the
  319. // server regardless of whether the field is empty or not. This may be
  320. // used to include empty fields in Patch requests.
  321. ForceSendFields []string `json:"-"`
  322. }
  323. func (s *AnalyzeModelDescription) MarshalJSON() ([]byte, error) {
  324. type noMethod AnalyzeModelDescription
  325. raw := noMethod(*s)
  326. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  327. }
  328. // AnalyzeModelDescriptionConfusionMatrix: An output confusion matrix.
  329. // This shows an estimate for how this model will do in predictions.
  330. // This is first indexed by the true class label. For each true class
  331. // label, this provides a pair {predicted_label, count}, where count is
  332. // the estimated number of times the model will predict the predicted
  333. // label given the true label. Will not output if more then 100 classes
  334. // [Categorical models only].
  335. type AnalyzeModelDescriptionConfusionMatrix struct {
  336. }
  337. // AnalyzeModelDescriptionConfusionMatrixRowTotals: A list of the
  338. // confusion matrix row totals
  339. type AnalyzeModelDescriptionConfusionMatrixRowTotals struct {
  340. }
  341. type Input struct {
  342. // Input: Input to the model for a prediction
  343. Input *InputInput `json:"input,omitempty"`
  344. // ForceSendFields is a list of field names (e.g. "Input") to
  345. // unconditionally include in API requests. By default, fields with
  346. // empty values are omitted from API requests. However, any non-pointer,
  347. // non-interface field appearing in ForceSendFields will be sent to the
  348. // server regardless of whether the field is empty or not. This may be
  349. // used to include empty fields in Patch requests.
  350. ForceSendFields []string `json:"-"`
  351. }
  352. func (s *Input) MarshalJSON() ([]byte, error) {
  353. type noMethod Input
  354. raw := noMethod(*s)
  355. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  356. }
  357. // InputInput: Input to the model for a prediction
  358. type InputInput struct {
  359. // CsvInstance: A list of input features, these can be strings or
  360. // doubles.
  361. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  362. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  363. // unconditionally include in API requests. By default, fields with
  364. // empty values are omitted from API requests. However, any non-pointer,
  365. // non-interface field appearing in ForceSendFields will be sent to the
  366. // server regardless of whether the field is empty or not. This may be
  367. // used to include empty fields in Patch requests.
  368. ForceSendFields []string `json:"-"`
  369. }
  370. func (s *InputInput) MarshalJSON() ([]byte, error) {
  371. type noMethod InputInput
  372. raw := noMethod(*s)
  373. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  374. }
  375. type List struct {
  376. // Items: List of models.
  377. Items []*Training `json:"items,omitempty"`
  378. // Kind: What kind of resource this is.
  379. Kind string `json:"kind,omitempty"`
  380. // NextPageToken: Pagination token to fetch the next page, if one
  381. // exists.
  382. NextPageToken string `json:"nextPageToken,omitempty"`
  383. // SelfLink: A URL to re-request this resource.
  384. SelfLink string `json:"selfLink,omitempty"`
  385. // ServerResponse contains the HTTP response code and headers from the
  386. // server.
  387. googleapi.ServerResponse `json:"-"`
  388. // ForceSendFields is a list of field names (e.g. "Items") to
  389. // unconditionally include in API requests. By default, fields with
  390. // empty values are omitted from API requests. However, any non-pointer,
  391. // non-interface field appearing in ForceSendFields will be sent to the
  392. // server regardless of whether the field is empty or not. This may be
  393. // used to include empty fields in Patch requests.
  394. ForceSendFields []string `json:"-"`
  395. }
  396. func (s *List) MarshalJSON() ([]byte, error) {
  397. type noMethod List
  398. raw := noMethod(*s)
  399. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  400. }
  401. type Output struct {
  402. // Id: The unique name for the predictive model.
  403. Id string `json:"id,omitempty"`
  404. // Kind: What kind of resource this is.
  405. Kind string `json:"kind,omitempty"`
  406. // OutputLabel: The most likely class label [Categorical models only].
  407. OutputLabel string `json:"outputLabel,omitempty"`
  408. // OutputMulti: A list of class labels with their estimated
  409. // probabilities [Categorical models only].
  410. OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
  411. // OutputValue: The estimated regression value [Regression models only].
  412. OutputValue float64 `json:"outputValue,omitempty"`
  413. // SelfLink: A URL to re-request this resource.
  414. SelfLink string `json:"selfLink,omitempty"`
  415. // ServerResponse contains the HTTP response code and headers from the
  416. // server.
  417. googleapi.ServerResponse `json:"-"`
  418. // ForceSendFields is a list of field names (e.g. "Id") to
  419. // unconditionally include in API requests. By default, fields with
  420. // empty values are omitted from API requests. However, any non-pointer,
  421. // non-interface field appearing in ForceSendFields will be sent to the
  422. // server regardless of whether the field is empty or not. This may be
  423. // used to include empty fields in Patch requests.
  424. ForceSendFields []string `json:"-"`
  425. }
  426. func (s *Output) MarshalJSON() ([]byte, error) {
  427. type noMethod Output
  428. raw := noMethod(*s)
  429. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  430. }
  431. type OutputOutputMulti struct {
  432. // Label: The class label.
  433. Label string `json:"label,omitempty"`
  434. // Score: The probability of the class label.
  435. Score float64 `json:"score,omitempty"`
  436. // ForceSendFields is a list of field names (e.g. "Label") to
  437. // unconditionally include in API requests. By default, fields with
  438. // empty values are omitted from API requests. However, any non-pointer,
  439. // non-interface field appearing in ForceSendFields will be sent to the
  440. // server regardless of whether the field is empty or not. This may be
  441. // used to include empty fields in Patch requests.
  442. ForceSendFields []string `json:"-"`
  443. }
  444. func (s *OutputOutputMulti) MarshalJSON() ([]byte, error) {
  445. type noMethod OutputOutputMulti
  446. raw := noMethod(*s)
  447. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  448. }
  449. type Training struct {
  450. // Created: Insert time of the model (as a RFC 3339 timestamp).
  451. Created string `json:"created,omitempty"`
  452. // Id: The unique name for the predictive model.
  453. Id string `json:"id,omitempty"`
  454. // Kind: What kind of resource this is.
  455. Kind string `json:"kind,omitempty"`
  456. // ModelInfo: Model metadata.
  457. ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
  458. // ModelType: Type of predictive model (classification or regression)
  459. ModelType string `json:"modelType,omitempty"`
  460. // SelfLink: A URL to re-request this resource.
  461. SelfLink string `json:"selfLink,omitempty"`
  462. // StorageDataLocation: Google storage location of the training data
  463. // file.
  464. StorageDataLocation string `json:"storageDataLocation,omitempty"`
  465. // StoragePMMLLocation: Google storage location of the preprocessing
  466. // pmml file.
  467. StoragePMMLLocation string `json:"storagePMMLLocation,omitempty"`
  468. // StoragePMMLModelLocation: Google storage location of the pmml model
  469. // file.
  470. StoragePMMLModelLocation string `json:"storagePMMLModelLocation,omitempty"`
  471. // TrainingComplete: Training completion time (as a RFC 3339 timestamp).
  472. TrainingComplete string `json:"trainingComplete,omitempty"`
  473. // TrainingInstances: Instances to train model on.
  474. TrainingInstances []*TrainingTrainingInstances `json:"trainingInstances,omitempty"`
  475. // TrainingStatus: The current status of the training job. This can be
  476. // one of following: RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND
  477. TrainingStatus string `json:"trainingStatus,omitempty"`
  478. // Utility: A class weighting function, which allows the importance
  479. // weights for class labels to be specified [Categorical models only].
  480. Utility []*TrainingUtility `json:"utility,omitempty"`
  481. // ServerResponse contains the HTTP response code and headers from the
  482. // server.
  483. googleapi.ServerResponse `json:"-"`
  484. // ForceSendFields is a list of field names (e.g. "Created") to
  485. // unconditionally include in API requests. By default, fields with
  486. // empty values are omitted from API requests. However, any non-pointer,
  487. // non-interface field appearing in ForceSendFields will be sent to the
  488. // server regardless of whether the field is empty or not. This may be
  489. // used to include empty fields in Patch requests.
  490. ForceSendFields []string `json:"-"`
  491. }
  492. func (s *Training) MarshalJSON() ([]byte, error) {
  493. type noMethod Training
  494. raw := noMethod(*s)
  495. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  496. }
  497. // TrainingModelInfo: Model metadata.
  498. type TrainingModelInfo struct {
  499. // ClassWeightedAccuracy: Estimated accuracy of model taking utility
  500. // weights into account [Categorical models only].
  501. ClassWeightedAccuracy float64 `json:"classWeightedAccuracy,omitempty"`
  502. // ClassificationAccuracy: A number between 0.0 and 1.0, where 1.0 is
  503. // 100% accurate. This is an estimate, based on the amount and quality
  504. // of the training data, of the estimated prediction accuracy. You can
  505. // use this is a guide to decide whether the results are accurate enough
  506. // for your needs. This estimate will be more reliable if your real
  507. // input data is similar to your training data [Categorical models
  508. // only].
  509. ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
  510. // MeanSquaredError: An estimated mean squared error. The can be used to
  511. // measure the quality of the predicted model [Regression models only].
  512. MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
  513. // ModelType: Type of predictive model (CLASSIFICATION or REGRESSION)
  514. ModelType string `json:"modelType,omitempty"`
  515. // NumberInstances: Number of valid data instances used in the trained
  516. // model.
  517. NumberInstances int64 `json:"numberInstances,omitempty,string"`
  518. // NumberLabels: Number of class labels in the trained model
  519. // [Categorical models only].
  520. NumberLabels int64 `json:"numberLabels,omitempty,string"`
  521. // ForceSendFields is a list of field names (e.g.
  522. // "ClassWeightedAccuracy") to unconditionally include in API requests.
  523. // By default, fields with empty values are omitted from API requests.
  524. // However, any non-pointer, non-interface field appearing in
  525. // ForceSendFields will be sent to the server regardless of whether the
  526. // field is empty or not. This may be used to include empty fields in
  527. // Patch requests.
  528. ForceSendFields []string `json:"-"`
  529. }
  530. func (s *TrainingModelInfo) MarshalJSON() ([]byte, error) {
  531. type noMethod TrainingModelInfo
  532. raw := noMethod(*s)
  533. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  534. }
  535. type TrainingTrainingInstances struct {
  536. // CsvInstance: The input features for this instance
  537. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  538. // Output: The generic output value - could be regression or class label
  539. Output string `json:"output,omitempty"`
  540. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  541. // unconditionally include in API requests. By default, fields with
  542. // empty values are omitted from API requests. However, any non-pointer,
  543. // non-interface field appearing in ForceSendFields will be sent to the
  544. // server regardless of whether the field is empty or not. This may be
  545. // used to include empty fields in Patch requests.
  546. ForceSendFields []string `json:"-"`
  547. }
  548. func (s *TrainingTrainingInstances) MarshalJSON() ([]byte, error) {
  549. type noMethod TrainingTrainingInstances
  550. raw := noMethod(*s)
  551. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  552. }
  553. // TrainingUtility: Class label (string).
  554. type TrainingUtility struct {
  555. }
  556. type Update struct {
  557. // CsvInstance: The input features for this instance
  558. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  559. // Label: The class label of this instance
  560. Label string `json:"label,omitempty"`
  561. // Output: The generic output value - could be regression value or class
  562. // label
  563. Output string `json:"output,omitempty"`
  564. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  565. // unconditionally include in API requests. By default, fields with
  566. // empty values are omitted from API requests. However, any non-pointer,
  567. // non-interface field appearing in ForceSendFields will be sent to the
  568. // server regardless of whether the field is empty or not. This may be
  569. // used to include empty fields in Patch requests.
  570. ForceSendFields []string `json:"-"`
  571. }
  572. func (s *Update) MarshalJSON() ([]byte, error) {
  573. type noMethod Update
  574. raw := noMethod(*s)
  575. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  576. }
  577. // method id "prediction.hostedmodels.predict":
  578. type HostedmodelsPredictCall struct {
  579. s *Service
  580. hostedModelName string
  581. input *Input
  582. urlParams_ gensupport.URLParams
  583. ctx_ context.Context
  584. }
  585. // Predict: Submit input and request an output against a hosted model.
  586. func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
  587. c := &HostedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  588. c.hostedModelName = hostedModelName
  589. c.input = input
  590. return c
  591. }
  592. // Fields allows partial responses to be retrieved. See
  593. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  594. // for more information.
  595. func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
  596. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  597. return c
  598. }
  599. // Context sets the context to be used in this call's Do method. Any
  600. // pending HTTP request will be aborted if the provided context is
  601. // canceled.
  602. func (c *HostedmodelsPredictCall) Context(ctx context.Context) *HostedmodelsPredictCall {
  603. c.ctx_ = ctx
  604. return c
  605. }
  606. func (c *HostedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  607. var body io.Reader = nil
  608. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  609. if err != nil {
  610. return nil, err
  611. }
  612. ctype := "application/json"
  613. c.urlParams_.Set("alt", alt)
  614. urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
  615. urls += "?" + c.urlParams_.Encode()
  616. req, _ := http.NewRequest("POST", urls, body)
  617. googleapi.Expand(req.URL, map[string]string{
  618. "hostedModelName": c.hostedModelName,
  619. })
  620. req.Header.Set("Content-Type", ctype)
  621. req.Header.Set("User-Agent", c.s.userAgent())
  622. if c.ctx_ != nil {
  623. return ctxhttp.Do(c.ctx_, c.s.client, req)
  624. }
  625. return c.s.client.Do(req)
  626. }
  627. // Do executes the "prediction.hostedmodels.predict" call.
  628. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  629. // code is an error. Response headers are in either
  630. // *Output.ServerResponse.Header or (if a response was returned at all)
  631. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  632. // check whether the returned error was because http.StatusNotModified
  633. // was returned.
  634. func (c *HostedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  635. gensupport.SetOptions(c.urlParams_, opts...)
  636. res, err := c.doRequest("json")
  637. if res != nil && res.StatusCode == http.StatusNotModified {
  638. if res.Body != nil {
  639. res.Body.Close()
  640. }
  641. return nil, &googleapi.Error{
  642. Code: res.StatusCode,
  643. Header: res.Header,
  644. }
  645. }
  646. if err != nil {
  647. return nil, err
  648. }
  649. defer googleapi.CloseBody(res)
  650. if err := googleapi.CheckResponse(res); err != nil {
  651. return nil, err
  652. }
  653. ret := &Output{
  654. ServerResponse: googleapi.ServerResponse{
  655. Header: res.Header,
  656. HTTPStatusCode: res.StatusCode,
  657. },
  658. }
  659. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  660. return nil, err
  661. }
  662. return ret, nil
  663. // {
  664. // "description": "Submit input and request an output against a hosted model.",
  665. // "httpMethod": "POST",
  666. // "id": "prediction.hostedmodels.predict",
  667. // "parameterOrder": [
  668. // "hostedModelName"
  669. // ],
  670. // "parameters": {
  671. // "hostedModelName": {
  672. // "description": "The name of a hosted model.",
  673. // "location": "path",
  674. // "required": true,
  675. // "type": "string"
  676. // }
  677. // },
  678. // "path": "hostedmodels/{hostedModelName}/predict",
  679. // "request": {
  680. // "$ref": "Input"
  681. // },
  682. // "response": {
  683. // "$ref": "Output"
  684. // },
  685. // "scopes": [
  686. // "https://www.googleapis.com/auth/prediction"
  687. // ]
  688. // }
  689. }
  690. // method id "prediction.trainedmodels.analyze":
  691. type TrainedmodelsAnalyzeCall struct {
  692. s *Service
  693. id string
  694. urlParams_ gensupport.URLParams
  695. ifNoneMatch_ string
  696. ctx_ context.Context
  697. }
  698. // Analyze: Get analysis of the model and the data the model was trained
  699. // on.
  700. func (r *TrainedmodelsService) Analyze(id string) *TrainedmodelsAnalyzeCall {
  701. c := &TrainedmodelsAnalyzeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  702. c.id = id
  703. return c
  704. }
  705. // Fields allows partial responses to be retrieved. See
  706. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  707. // for more information.
  708. func (c *TrainedmodelsAnalyzeCall) Fields(s ...googleapi.Field) *TrainedmodelsAnalyzeCall {
  709. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  710. return c
  711. }
  712. // IfNoneMatch sets the optional parameter which makes the operation
  713. // fail if the object's ETag matches the given value. This is useful for
  714. // getting updates only after the object has changed since the last
  715. // request. Use googleapi.IsNotModified to check whether the response
  716. // error from Do is the result of In-None-Match.
  717. func (c *TrainedmodelsAnalyzeCall) IfNoneMatch(entityTag string) *TrainedmodelsAnalyzeCall {
  718. c.ifNoneMatch_ = entityTag
  719. return c
  720. }
  721. // Context sets the context to be used in this call's Do method. Any
  722. // pending HTTP request will be aborted if the provided context is
  723. // canceled.
  724. func (c *TrainedmodelsAnalyzeCall) Context(ctx context.Context) *TrainedmodelsAnalyzeCall {
  725. c.ctx_ = ctx
  726. return c
  727. }
  728. func (c *TrainedmodelsAnalyzeCall) doRequest(alt string) (*http.Response, error) {
  729. var body io.Reader = nil
  730. c.urlParams_.Set("alt", alt)
  731. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/analyze")
  732. urls += "?" + c.urlParams_.Encode()
  733. req, _ := http.NewRequest("GET", urls, body)
  734. googleapi.Expand(req.URL, map[string]string{
  735. "id": c.id,
  736. })
  737. req.Header.Set("User-Agent", c.s.userAgent())
  738. if c.ifNoneMatch_ != "" {
  739. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  740. }
  741. if c.ctx_ != nil {
  742. return ctxhttp.Do(c.ctx_, c.s.client, req)
  743. }
  744. return c.s.client.Do(req)
  745. }
  746. // Do executes the "prediction.trainedmodels.analyze" call.
  747. // Exactly one of *Analyze or error will be non-nil. Any non-2xx status
  748. // code is an error. Response headers are in either
  749. // *Analyze.ServerResponse.Header or (if a response was returned at all)
  750. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  751. // check whether the returned error was because http.StatusNotModified
  752. // was returned.
  753. func (c *TrainedmodelsAnalyzeCall) Do(opts ...googleapi.CallOption) (*Analyze, error) {
  754. gensupport.SetOptions(c.urlParams_, opts...)
  755. res, err := c.doRequest("json")
  756. if res != nil && res.StatusCode == http.StatusNotModified {
  757. if res.Body != nil {
  758. res.Body.Close()
  759. }
  760. return nil, &googleapi.Error{
  761. Code: res.StatusCode,
  762. Header: res.Header,
  763. }
  764. }
  765. if err != nil {
  766. return nil, err
  767. }
  768. defer googleapi.CloseBody(res)
  769. if err := googleapi.CheckResponse(res); err != nil {
  770. return nil, err
  771. }
  772. ret := &Analyze{
  773. ServerResponse: googleapi.ServerResponse{
  774. Header: res.Header,
  775. HTTPStatusCode: res.StatusCode,
  776. },
  777. }
  778. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  779. return nil, err
  780. }
  781. return ret, nil
  782. // {
  783. // "description": "Get analysis of the model and the data the model was trained on.",
  784. // "httpMethod": "GET",
  785. // "id": "prediction.trainedmodels.analyze",
  786. // "parameterOrder": [
  787. // "id"
  788. // ],
  789. // "parameters": {
  790. // "id": {
  791. // "description": "The unique name for the predictive model.",
  792. // "location": "path",
  793. // "required": true,
  794. // "type": "string"
  795. // }
  796. // },
  797. // "path": "trainedmodels/{id}/analyze",
  798. // "response": {
  799. // "$ref": "Analyze"
  800. // },
  801. // "scopes": [
  802. // "https://www.googleapis.com/auth/prediction"
  803. // ]
  804. // }
  805. }
  806. // method id "prediction.trainedmodels.delete":
  807. type TrainedmodelsDeleteCall struct {
  808. s *Service
  809. id string
  810. urlParams_ gensupport.URLParams
  811. ctx_ context.Context
  812. }
  813. // Delete: Delete a trained model.
  814. func (r *TrainedmodelsService) Delete(id string) *TrainedmodelsDeleteCall {
  815. c := &TrainedmodelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  816. c.id = id
  817. return c
  818. }
  819. // Fields allows partial responses to be retrieved. See
  820. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  821. // for more information.
  822. func (c *TrainedmodelsDeleteCall) Fields(s ...googleapi.Field) *TrainedmodelsDeleteCall {
  823. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  824. return c
  825. }
  826. // Context sets the context to be used in this call's Do method. Any
  827. // pending HTTP request will be aborted if the provided context is
  828. // canceled.
  829. func (c *TrainedmodelsDeleteCall) Context(ctx context.Context) *TrainedmodelsDeleteCall {
  830. c.ctx_ = ctx
  831. return c
  832. }
  833. func (c *TrainedmodelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  834. var body io.Reader = nil
  835. c.urlParams_.Set("alt", alt)
  836. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  837. urls += "?" + c.urlParams_.Encode()
  838. req, _ := http.NewRequest("DELETE", urls, body)
  839. googleapi.Expand(req.URL, map[string]string{
  840. "id": c.id,
  841. })
  842. req.Header.Set("User-Agent", c.s.userAgent())
  843. if c.ctx_ != nil {
  844. return ctxhttp.Do(c.ctx_, c.s.client, req)
  845. }
  846. return c.s.client.Do(req)
  847. }
  848. // Do executes the "prediction.trainedmodels.delete" call.
  849. func (c *TrainedmodelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  850. gensupport.SetOptions(c.urlParams_, opts...)
  851. res, err := c.doRequest("json")
  852. if err != nil {
  853. return err
  854. }
  855. defer googleapi.CloseBody(res)
  856. if err := googleapi.CheckResponse(res); err != nil {
  857. return err
  858. }
  859. return nil
  860. // {
  861. // "description": "Delete a trained model.",
  862. // "httpMethod": "DELETE",
  863. // "id": "prediction.trainedmodels.delete",
  864. // "parameterOrder": [
  865. // "id"
  866. // ],
  867. // "parameters": {
  868. // "id": {
  869. // "description": "The unique name for the predictive model.",
  870. // "location": "path",
  871. // "required": true,
  872. // "type": "string"
  873. // }
  874. // },
  875. // "path": "trainedmodels/{id}",
  876. // "scopes": [
  877. // "https://www.googleapis.com/auth/prediction"
  878. // ]
  879. // }
  880. }
  881. // method id "prediction.trainedmodels.get":
  882. type TrainedmodelsGetCall struct {
  883. s *Service
  884. id string
  885. urlParams_ gensupport.URLParams
  886. ifNoneMatch_ string
  887. ctx_ context.Context
  888. }
  889. // Get: Check training status of your model.
  890. func (r *TrainedmodelsService) Get(id string) *TrainedmodelsGetCall {
  891. c := &TrainedmodelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  892. c.id = id
  893. return c
  894. }
  895. // Fields allows partial responses to be retrieved. See
  896. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  897. // for more information.
  898. func (c *TrainedmodelsGetCall) Fields(s ...googleapi.Field) *TrainedmodelsGetCall {
  899. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  900. return c
  901. }
  902. // IfNoneMatch sets the optional parameter which makes the operation
  903. // fail if the object's ETag matches the given value. This is useful for
  904. // getting updates only after the object has changed since the last
  905. // request. Use googleapi.IsNotModified to check whether the response
  906. // error from Do is the result of In-None-Match.
  907. func (c *TrainedmodelsGetCall) IfNoneMatch(entityTag string) *TrainedmodelsGetCall {
  908. c.ifNoneMatch_ = entityTag
  909. return c
  910. }
  911. // Context sets the context to be used in this call's Do method. Any
  912. // pending HTTP request will be aborted if the provided context is
  913. // canceled.
  914. func (c *TrainedmodelsGetCall) Context(ctx context.Context) *TrainedmodelsGetCall {
  915. c.ctx_ = ctx
  916. return c
  917. }
  918. func (c *TrainedmodelsGetCall) doRequest(alt string) (*http.Response, error) {
  919. var body io.Reader = nil
  920. c.urlParams_.Set("alt", alt)
  921. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  922. urls += "?" + c.urlParams_.Encode()
  923. req, _ := http.NewRequest("GET", urls, body)
  924. googleapi.Expand(req.URL, map[string]string{
  925. "id": c.id,
  926. })
  927. req.Header.Set("User-Agent", c.s.userAgent())
  928. if c.ifNoneMatch_ != "" {
  929. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  930. }
  931. if c.ctx_ != nil {
  932. return ctxhttp.Do(c.ctx_, c.s.client, req)
  933. }
  934. return c.s.client.Do(req)
  935. }
  936. // Do executes the "prediction.trainedmodels.get" call.
  937. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  938. // code is an error. Response headers are in either
  939. // *Training.ServerResponse.Header or (if a response was returned at
  940. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  941. // to check whether the returned error was because
  942. // http.StatusNotModified was returned.
  943. func (c *TrainedmodelsGetCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  944. gensupport.SetOptions(c.urlParams_, opts...)
  945. res, err := c.doRequest("json")
  946. if res != nil && res.StatusCode == http.StatusNotModified {
  947. if res.Body != nil {
  948. res.Body.Close()
  949. }
  950. return nil, &googleapi.Error{
  951. Code: res.StatusCode,
  952. Header: res.Header,
  953. }
  954. }
  955. if err != nil {
  956. return nil, err
  957. }
  958. defer googleapi.CloseBody(res)
  959. if err := googleapi.CheckResponse(res); err != nil {
  960. return nil, err
  961. }
  962. ret := &Training{
  963. ServerResponse: googleapi.ServerResponse{
  964. Header: res.Header,
  965. HTTPStatusCode: res.StatusCode,
  966. },
  967. }
  968. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  969. return nil, err
  970. }
  971. return ret, nil
  972. // {
  973. // "description": "Check training status of your model.",
  974. // "httpMethod": "GET",
  975. // "id": "prediction.trainedmodels.get",
  976. // "parameterOrder": [
  977. // "id"
  978. // ],
  979. // "parameters": {
  980. // "id": {
  981. // "description": "The unique name for the predictive model.",
  982. // "location": "path",
  983. // "required": true,
  984. // "type": "string"
  985. // }
  986. // },
  987. // "path": "trainedmodels/{id}",
  988. // "response": {
  989. // "$ref": "Training"
  990. // },
  991. // "scopes": [
  992. // "https://www.googleapis.com/auth/prediction"
  993. // ]
  994. // }
  995. }
  996. // method id "prediction.trainedmodels.insert":
  997. type TrainedmodelsInsertCall struct {
  998. s *Service
  999. training *Training
  1000. urlParams_ gensupport.URLParams
  1001. ctx_ context.Context
  1002. }
  1003. // Insert: Begin training your model.
  1004. func (r *TrainedmodelsService) Insert(training *Training) *TrainedmodelsInsertCall {
  1005. c := &TrainedmodelsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1006. c.training = training
  1007. return c
  1008. }
  1009. // Fields allows partial responses to be retrieved. See
  1010. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1011. // for more information.
  1012. func (c *TrainedmodelsInsertCall) Fields(s ...googleapi.Field) *TrainedmodelsInsertCall {
  1013. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1014. return c
  1015. }
  1016. // Context sets the context to be used in this call's Do method. Any
  1017. // pending HTTP request will be aborted if the provided context is
  1018. // canceled.
  1019. func (c *TrainedmodelsInsertCall) Context(ctx context.Context) *TrainedmodelsInsertCall {
  1020. c.ctx_ = ctx
  1021. return c
  1022. }
  1023. func (c *TrainedmodelsInsertCall) doRequest(alt string) (*http.Response, error) {
  1024. var body io.Reader = nil
  1025. body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
  1026. if err != nil {
  1027. return nil, err
  1028. }
  1029. ctype := "application/json"
  1030. c.urlParams_.Set("alt", alt)
  1031. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels")
  1032. urls += "?" + c.urlParams_.Encode()
  1033. req, _ := http.NewRequest("POST", urls, body)
  1034. googleapi.SetOpaque(req.URL)
  1035. req.Header.Set("Content-Type", ctype)
  1036. req.Header.Set("User-Agent", c.s.userAgent())
  1037. if c.ctx_ != nil {
  1038. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1039. }
  1040. return c.s.client.Do(req)
  1041. }
  1042. // Do executes the "prediction.trainedmodels.insert" call.
  1043. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1044. // code is an error. Response headers are in either
  1045. // *Training.ServerResponse.Header or (if a response was returned at
  1046. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1047. // to check whether the returned error was because
  1048. // http.StatusNotModified was returned.
  1049. func (c *TrainedmodelsInsertCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1050. gensupport.SetOptions(c.urlParams_, opts...)
  1051. res, err := c.doRequest("json")
  1052. if res != nil && res.StatusCode == http.StatusNotModified {
  1053. if res.Body != nil {
  1054. res.Body.Close()
  1055. }
  1056. return nil, &googleapi.Error{
  1057. Code: res.StatusCode,
  1058. Header: res.Header,
  1059. }
  1060. }
  1061. if err != nil {
  1062. return nil, err
  1063. }
  1064. defer googleapi.CloseBody(res)
  1065. if err := googleapi.CheckResponse(res); err != nil {
  1066. return nil, err
  1067. }
  1068. ret := &Training{
  1069. ServerResponse: googleapi.ServerResponse{
  1070. Header: res.Header,
  1071. HTTPStatusCode: res.StatusCode,
  1072. },
  1073. }
  1074. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1075. return nil, err
  1076. }
  1077. return ret, nil
  1078. // {
  1079. // "description": "Begin training your model.",
  1080. // "httpMethod": "POST",
  1081. // "id": "prediction.trainedmodels.insert",
  1082. // "path": "trainedmodels",
  1083. // "request": {
  1084. // "$ref": "Training"
  1085. // },
  1086. // "response": {
  1087. // "$ref": "Training"
  1088. // },
  1089. // "scopes": [
  1090. // "https://www.googleapis.com/auth/devstorage.full_control",
  1091. // "https://www.googleapis.com/auth/devstorage.read_only",
  1092. // "https://www.googleapis.com/auth/devstorage.read_write",
  1093. // "https://www.googleapis.com/auth/prediction"
  1094. // ]
  1095. // }
  1096. }
  1097. // method id "prediction.trainedmodels.list":
  1098. type TrainedmodelsListCall struct {
  1099. s *Service
  1100. urlParams_ gensupport.URLParams
  1101. ifNoneMatch_ string
  1102. ctx_ context.Context
  1103. }
  1104. // List: List available models.
  1105. func (r *TrainedmodelsService) List() *TrainedmodelsListCall {
  1106. c := &TrainedmodelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1107. return c
  1108. }
  1109. // MaxResults sets the optional parameter "maxResults": Maximum number
  1110. // of results to return
  1111. func (c *TrainedmodelsListCall) MaxResults(maxResults int64) *TrainedmodelsListCall {
  1112. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1113. return c
  1114. }
  1115. // PageToken sets the optional parameter "pageToken": Pagination token
  1116. func (c *TrainedmodelsListCall) PageToken(pageToken string) *TrainedmodelsListCall {
  1117. c.urlParams_.Set("pageToken", pageToken)
  1118. return c
  1119. }
  1120. // Fields allows partial responses to be retrieved. See
  1121. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1122. // for more information.
  1123. func (c *TrainedmodelsListCall) Fields(s ...googleapi.Field) *TrainedmodelsListCall {
  1124. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1125. return c
  1126. }
  1127. // IfNoneMatch sets the optional parameter which makes the operation
  1128. // fail if the object's ETag matches the given value. This is useful for
  1129. // getting updates only after the object has changed since the last
  1130. // request. Use googleapi.IsNotModified to check whether the response
  1131. // error from Do is the result of In-None-Match.
  1132. func (c *TrainedmodelsListCall) IfNoneMatch(entityTag string) *TrainedmodelsListCall {
  1133. c.ifNoneMatch_ = entityTag
  1134. return c
  1135. }
  1136. // Context sets the context to be used in this call's Do method. Any
  1137. // pending HTTP request will be aborted if the provided context is
  1138. // canceled.
  1139. func (c *TrainedmodelsListCall) Context(ctx context.Context) *TrainedmodelsListCall {
  1140. c.ctx_ = ctx
  1141. return c
  1142. }
  1143. func (c *TrainedmodelsListCall) doRequest(alt string) (*http.Response, error) {
  1144. var body io.Reader = nil
  1145. c.urlParams_.Set("alt", alt)
  1146. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/list")
  1147. urls += "?" + c.urlParams_.Encode()
  1148. req, _ := http.NewRequest("GET", urls, body)
  1149. googleapi.SetOpaque(req.URL)
  1150. req.Header.Set("User-Agent", c.s.userAgent())
  1151. if c.ifNoneMatch_ != "" {
  1152. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1153. }
  1154. if c.ctx_ != nil {
  1155. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1156. }
  1157. return c.s.client.Do(req)
  1158. }
  1159. // Do executes the "prediction.trainedmodels.list" call.
  1160. // Exactly one of *List or error will be non-nil. Any non-2xx status
  1161. // code is an error. Response headers are in either
  1162. // *List.ServerResponse.Header or (if a response was returned at all) in
  1163. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1164. // whether the returned error was because http.StatusNotModified was
  1165. // returned.
  1166. func (c *TrainedmodelsListCall) Do(opts ...googleapi.CallOption) (*List, error) {
  1167. gensupport.SetOptions(c.urlParams_, opts...)
  1168. res, err := c.doRequest("json")
  1169. if res != nil && res.StatusCode == http.StatusNotModified {
  1170. if res.Body != nil {
  1171. res.Body.Close()
  1172. }
  1173. return nil, &googleapi.Error{
  1174. Code: res.StatusCode,
  1175. Header: res.Header,
  1176. }
  1177. }
  1178. if err != nil {
  1179. return nil, err
  1180. }
  1181. defer googleapi.CloseBody(res)
  1182. if err := googleapi.CheckResponse(res); err != nil {
  1183. return nil, err
  1184. }
  1185. ret := &List{
  1186. ServerResponse: googleapi.ServerResponse{
  1187. Header: res.Header,
  1188. HTTPStatusCode: res.StatusCode,
  1189. },
  1190. }
  1191. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1192. return nil, err
  1193. }
  1194. return ret, nil
  1195. // {
  1196. // "description": "List available models.",
  1197. // "httpMethod": "GET",
  1198. // "id": "prediction.trainedmodels.list",
  1199. // "parameters": {
  1200. // "maxResults": {
  1201. // "description": "Maximum number of results to return",
  1202. // "format": "uint32",
  1203. // "location": "query",
  1204. // "minimum": "0",
  1205. // "type": "integer"
  1206. // },
  1207. // "pageToken": {
  1208. // "description": "Pagination token",
  1209. // "location": "query",
  1210. // "type": "string"
  1211. // }
  1212. // },
  1213. // "path": "trainedmodels/list",
  1214. // "response": {
  1215. // "$ref": "List"
  1216. // },
  1217. // "scopes": [
  1218. // "https://www.googleapis.com/auth/prediction"
  1219. // ]
  1220. // }
  1221. }
  1222. // Pages invokes f for each page of results.
  1223. // A non-nil error returned from f will halt the iteration.
  1224. // The provided context supersedes any context provided to the Context method.
  1225. func (c *TrainedmodelsListCall) Pages(ctx context.Context, f func(*List) error) error {
  1226. c.ctx_ = ctx
  1227. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1228. for {
  1229. x, err := c.Do()
  1230. if err != nil {
  1231. return err
  1232. }
  1233. if err := f(x); err != nil {
  1234. return err
  1235. }
  1236. if x.NextPageToken == "" {
  1237. return nil
  1238. }
  1239. c.PageToken(x.NextPageToken)
  1240. }
  1241. }
  1242. // method id "prediction.trainedmodels.predict":
  1243. type TrainedmodelsPredictCall struct {
  1244. s *Service
  1245. id string
  1246. input *Input
  1247. urlParams_ gensupport.URLParams
  1248. ctx_ context.Context
  1249. }
  1250. // Predict: Submit model id and request a prediction.
  1251. func (r *TrainedmodelsService) Predict(id string, input *Input) *TrainedmodelsPredictCall {
  1252. c := &TrainedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1253. c.id = id
  1254. c.input = input
  1255. return c
  1256. }
  1257. // Fields allows partial responses to be retrieved. See
  1258. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1259. // for more information.
  1260. func (c *TrainedmodelsPredictCall) Fields(s ...googleapi.Field) *TrainedmodelsPredictCall {
  1261. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1262. return c
  1263. }
  1264. // Context sets the context to be used in this call's Do method. Any
  1265. // pending HTTP request will be aborted if the provided context is
  1266. // canceled.
  1267. func (c *TrainedmodelsPredictCall) Context(ctx context.Context) *TrainedmodelsPredictCall {
  1268. c.ctx_ = ctx
  1269. return c
  1270. }
  1271. func (c *TrainedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  1272. var body io.Reader = nil
  1273. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  1274. if err != nil {
  1275. return nil, err
  1276. }
  1277. ctype := "application/json"
  1278. c.urlParams_.Set("alt", alt)
  1279. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/predict")
  1280. urls += "?" + c.urlParams_.Encode()
  1281. req, _ := http.NewRequest("POST", urls, body)
  1282. googleapi.Expand(req.URL, map[string]string{
  1283. "id": c.id,
  1284. })
  1285. req.Header.Set("Content-Type", ctype)
  1286. req.Header.Set("User-Agent", c.s.userAgent())
  1287. if c.ctx_ != nil {
  1288. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1289. }
  1290. return c.s.client.Do(req)
  1291. }
  1292. // Do executes the "prediction.trainedmodels.predict" call.
  1293. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  1294. // code is an error. Response headers are in either
  1295. // *Output.ServerResponse.Header or (if a response was returned at all)
  1296. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1297. // check whether the returned error was because http.StatusNotModified
  1298. // was returned.
  1299. func (c *TrainedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  1300. gensupport.SetOptions(c.urlParams_, opts...)
  1301. res, err := c.doRequest("json")
  1302. if res != nil && res.StatusCode == http.StatusNotModified {
  1303. if res.Body != nil {
  1304. res.Body.Close()
  1305. }
  1306. return nil, &googleapi.Error{
  1307. Code: res.StatusCode,
  1308. Header: res.Header,
  1309. }
  1310. }
  1311. if err != nil {
  1312. return nil, err
  1313. }
  1314. defer googleapi.CloseBody(res)
  1315. if err := googleapi.CheckResponse(res); err != nil {
  1316. return nil, err
  1317. }
  1318. ret := &Output{
  1319. ServerResponse: googleapi.ServerResponse{
  1320. Header: res.Header,
  1321. HTTPStatusCode: res.StatusCode,
  1322. },
  1323. }
  1324. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1325. return nil, err
  1326. }
  1327. return ret, nil
  1328. // {
  1329. // "description": "Submit model id and request a prediction.",
  1330. // "httpMethod": "POST",
  1331. // "id": "prediction.trainedmodels.predict",
  1332. // "parameterOrder": [
  1333. // "id"
  1334. // ],
  1335. // "parameters": {
  1336. // "id": {
  1337. // "description": "The unique name for the predictive model.",
  1338. // "location": "path",
  1339. // "required": true,
  1340. // "type": "string"
  1341. // }
  1342. // },
  1343. // "path": "trainedmodels/{id}/predict",
  1344. // "request": {
  1345. // "$ref": "Input"
  1346. // },
  1347. // "response": {
  1348. // "$ref": "Output"
  1349. // },
  1350. // "scopes": [
  1351. // "https://www.googleapis.com/auth/prediction"
  1352. // ]
  1353. // }
  1354. }
  1355. // method id "prediction.trainedmodels.update":
  1356. type TrainedmodelsUpdateCall struct {
  1357. s *Service
  1358. id string
  1359. update *Update
  1360. urlParams_ gensupport.URLParams
  1361. ctx_ context.Context
  1362. }
  1363. // Update: Add new data to a trained model.
  1364. func (r *TrainedmodelsService) Update(id string, update *Update) *TrainedmodelsUpdateCall {
  1365. c := &TrainedmodelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1366. c.id = id
  1367. c.update = update
  1368. return c
  1369. }
  1370. // Fields allows partial responses to be retrieved. See
  1371. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1372. // for more information.
  1373. func (c *TrainedmodelsUpdateCall) Fields(s ...googleapi.Field) *TrainedmodelsUpdateCall {
  1374. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1375. return c
  1376. }
  1377. // Context sets the context to be used in this call's Do method. Any
  1378. // pending HTTP request will be aborted if the provided context is
  1379. // canceled.
  1380. func (c *TrainedmodelsUpdateCall) Context(ctx context.Context) *TrainedmodelsUpdateCall {
  1381. c.ctx_ = ctx
  1382. return c
  1383. }
  1384. func (c *TrainedmodelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1385. var body io.Reader = nil
  1386. body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
  1387. if err != nil {
  1388. return nil, err
  1389. }
  1390. ctype := "application/json"
  1391. c.urlParams_.Set("alt", alt)
  1392. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  1393. urls += "?" + c.urlParams_.Encode()
  1394. req, _ := http.NewRequest("PUT", urls, body)
  1395. googleapi.Expand(req.URL, map[string]string{
  1396. "id": c.id,
  1397. })
  1398. req.Header.Set("Content-Type", ctype)
  1399. req.Header.Set("User-Agent", c.s.userAgent())
  1400. if c.ctx_ != nil {
  1401. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1402. }
  1403. return c.s.client.Do(req)
  1404. }
  1405. // Do executes the "prediction.trainedmodels.update" call.
  1406. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1407. // code is an error. Response headers are in either
  1408. // *Training.ServerResponse.Header or (if a response was returned at
  1409. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1410. // to check whether the returned error was because
  1411. // http.StatusNotModified was returned.
  1412. func (c *TrainedmodelsUpdateCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1413. gensupport.SetOptions(c.urlParams_, opts...)
  1414. res, err := c.doRequest("json")
  1415. if res != nil && res.StatusCode == http.StatusNotModified {
  1416. if res.Body != nil {
  1417. res.Body.Close()
  1418. }
  1419. return nil, &googleapi.Error{
  1420. Code: res.StatusCode,
  1421. Header: res.Header,
  1422. }
  1423. }
  1424. if err != nil {
  1425. return nil, err
  1426. }
  1427. defer googleapi.CloseBody(res)
  1428. if err := googleapi.CheckResponse(res); err != nil {
  1429. return nil, err
  1430. }
  1431. ret := &Training{
  1432. ServerResponse: googleapi.ServerResponse{
  1433. Header: res.Header,
  1434. HTTPStatusCode: res.StatusCode,
  1435. },
  1436. }
  1437. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1438. return nil, err
  1439. }
  1440. return ret, nil
  1441. // {
  1442. // "description": "Add new data to a trained model.",
  1443. // "httpMethod": "PUT",
  1444. // "id": "prediction.trainedmodels.update",
  1445. // "parameterOrder": [
  1446. // "id"
  1447. // ],
  1448. // "parameters": {
  1449. // "id": {
  1450. // "description": "The unique name for the predictive model.",
  1451. // "location": "path",
  1452. // "required": true,
  1453. // "type": "string"
  1454. // }
  1455. // },
  1456. // "path": "trainedmodels/{id}",
  1457. // "request": {
  1458. // "$ref": "Update"
  1459. // },
  1460. // "response": {
  1461. // "$ref": "Training"
  1462. // },
  1463. // "scopes": [
  1464. // "https://www.googleapis.com/auth/prediction"
  1465. // ]
  1466. // }
  1467. }