PluginProbe
Gianism / 1.1
Gianism v1.1
4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.4.0 5.0.0 5.0.1 5.0.2 5.1.0 5.2.1 5.2.2 5.3.0 6.0.0 6.0.1 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 65 releases
gianism / sdks / google / contrib / apiPredictionService.php

apiPredictionService.php in Gianism 1.1, at sdks/google/contrib/apiPredictionService.php

425 lines 13.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Copyright (c) 2010 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18 require_once 'service/apiModel.php';
19 require_once 'service/apiService.php';
20 require_once 'service/apiServiceRequest.php';
21
22
23 /**
24 * The "trainedmodels" collection of methods.
25 * Typical usage is:
26 * <code>
27 * $predictionService = new apiPredictionService(...);
28 * $trainedmodels = $predictionService->trainedmodels;
29 * </code>
30 */
31 class TrainedmodelsServiceResource extends apiServiceResource {
32
33
34 /**
35 * Submit model id and request a prediction (trainedmodels.predict)
36 *
37 * @param string $id The unique name for the predictive model.
38 * @param Input $postBody
39 * @return Output
40 */
41 public function predict($id, Input $postBody, $optParams = array()) {
42 $params = array('id' => $id, 'postBody' => $postBody);
43 $params = array_merge($params, $optParams);
44 $data = $this->__call('predict', array($params));
45 if ($this->useObjects()) {
46 return new Output($data);
47 } else {
48 return $data;
49 }
50 }
51 /**
52 * Begin training your model. (trainedmodels.insert)
53 *
54 * @param Training $postBody
55 * @return Training
56 */
57 public function insert(Training $postBody, $optParams = array()) {
58 $params = array('postBody' => $postBody);
59 $params = array_merge($params, $optParams);
60 $data = $this->__call('insert', array($params));
61 if ($this->useObjects()) {
62 return new Training($data);
63 } else {
64 return $data;
65 }
66 }
67 /**
68 * Check training status of your model. (trainedmodels.get)
69 *
70 * @param string $id The unique name for the predictive model.
71 * @return Training
72 */
73 public function get($id, $optParams = array()) {
74 $params = array('id' => $id);
75 $params = array_merge($params, $optParams);
76 $data = $this->__call('get', array($params));
77 if ($this->useObjects()) {
78 return new Training($data);
79 } else {
80 return $data;
81 }
82 }
83 /**
84 * Add new data to a trained model. (trainedmodels.update)
85 *
86 * @param string $id The unique name for the predictive model.
87 * @param Update $postBody
88 * @return Training
89 */
90 public function update($id, Update $postBody, $optParams = array()) {
91 $params = array('id' => $id, 'postBody' => $postBody);
92 $params = array_merge($params, $optParams);
93 $data = $this->__call('update', array($params));
94 if ($this->useObjects()) {
95 return new Training($data);
96 } else {
97 return $data;
98 }
99 }
100 /**
101 * Delete a trained model. (trainedmodels.delete)
102 *
103 * @param string $id The unique name for the predictive model.
104 */
105 public function delete($id, $optParams = array()) {
106 $params = array('id' => $id);
107 $params = array_merge($params, $optParams);
108 $data = $this->__call('delete', array($params));
109 return $data;
110 }
111 }
112
113 /**
114 * The "hostedmodels" collection of methods.
115 * Typical usage is:
116 * <code>
117 * $predictionService = new apiPredictionService(...);
118 * $hostedmodels = $predictionService->hostedmodels;
119 * </code>
120 */
121 class HostedmodelsServiceResource extends apiServiceResource {
122
123
124 /**
125 * Submit input and request an output against a hosted model. (hostedmodels.predict)
126 *
127 * @param string $hostedModelName The name of a hosted model.
128 * @param Input $postBody
129 * @return Output
130 */
131 public function predict($hostedModelName, Input $postBody, $optParams = array()) {
132 $params = array('hostedModelName' => $hostedModelName, 'postBody' => $postBody);
133 $params = array_merge($params, $optParams);
134 $data = $this->__call('predict', array($params));
135 if ($this->useObjects()) {
136 return new Output($data);
137 } else {
138 return $data;
139 }
140 }
141 }
142
143
144
145 /**
146 * Service definition for Prediction (v1.4).
147 *
148 * <p>
149 * Lets you access a cloud hosted machine learning service that makes it easy to build smart apps
150 * </p>
151 *
152 * <p>
153 * For more information about this service, see the
154 * <a href="http://code.google.com/apis/predict/docs/developer-guide.html" target="_blank">API Documentation</a>
155 * </p>
156 *
157 * @author Google, Inc.
158 */
159 class apiPredictionService extends apiService {
160 public $trainedmodels;
161 public $hostedmodels;
162 /**
163 * Constructs the internal representation of the Prediction service.
164 *
165 * @param apiClient apiClient
166 */
167 public function __construct(apiClient $apiClient) {
168 $this->rpcPath = '/rpc';
169 $this->restBasePath = '/prediction/v1.4/';
170 $this->version = 'v1.4';
171 $this->serviceName = 'prediction';
172
173 $apiClient->addService($this->serviceName, $this->version);
174 $this->trainedmodels = new TrainedmodelsServiceResource($this, $this->serviceName, 'trainedmodels', json_decode('{"methods": {"predict": {"scopes": ["https://www.googleapis.com/auth/prediction"], "parameters": {"id": {"required": true, "type": "string", "location": "path"}}, "request": {"$ref": "Input"}, "id": "prediction.trainedmodels.predict", "httpMethod": "POST", "path": "trainedmodels/{id}/predict", "response": {"$ref": "Output"}}, "insert": {"scopes": ["https://www.googleapis.com/auth/prediction"], "request": {"$ref": "Training"}, "response": {"$ref": "Training"}, "httpMethod": "POST", "path": "trainedmodels", "id": "prediction.trainedmodels.insert"}, "delete": {"scopes": ["https://www.googleapis.com/auth/prediction"], "parameters": {"id": {"required": true, "type": "string", "location": "path"}}, "httpMethod": "DELETE", "path": "trainedmodels/{id}", "id": "prediction.trainedmodels.delete"}, "update": {"scopes": ["https://www.googleapis.com/auth/prediction"], "parameters": {"id": {"required": true, "type": "string", "location": "path"}}, "request": {"$ref": "Update"}, "id": "prediction.trainedmodels.update", "httpMethod": "PUT", "path": "trainedmodels/{id}", "response": {"$ref": "Training"}}, "get": {"scopes": ["https://www.googleapis.com/auth/prediction"], "parameters": {"id": {"required": true, "type": "string", "location": "path"}}, "id": "prediction.trainedmodels.get", "httpMethod": "GET", "path": "trainedmodels/{id}", "response": {"$ref": "Training"}}}}', true));
175 $this->hostedmodels = new HostedmodelsServiceResource($this, $this->serviceName, 'hostedmodels', json_decode('{"methods": {"predict": {"scopes": ["https://www.googleapis.com/auth/prediction"], "parameters": {"hostedModelName": {"required": true, "type": "string", "location": "path"}}, "request": {"$ref": "Input"}, "id": "prediction.hostedmodels.predict", "httpMethod": "POST", "path": "hostedmodels/{hostedModelName}/predict", "response": {"$ref": "Output"}}}}', true));
176 }
177 }
178
179 class Input extends apiModel {
180 protected $__inputType = 'InputInput';
181 protected $__inputDataType = '';
182 public $input;
183 public function setInput(InputInput $input) {
184 $this->input = $input;
185 }
186 public function getInput() {
187 return $this->input;
188 }
189 }
190
191 class InputInput extends apiModel {
192 public $csvInstance;
193 public function setCsvInstance(/* array(object) */ $csvInstance) {
194 $this->assertIsArray($csvInstance, 'object', __METHOD__);
195 $this->csvInstance = $csvInstance;
196 }
197 public function getCsvInstance() {
198 return $this->csvInstance;
199 }
200 }
201
202 class Output extends apiModel {
203 public $kind;
204 public $outputLabel;
205 public $id;
206 protected $__outputMultiType = 'OutputOutputMulti';
207 protected $__outputMultiDataType = 'array';
208 public $outputMulti;
209 public $outputValue;
210 public $selfLink;
211 public function setKind($kind) {
212 $this->kind = $kind;
213 }
214 public function getKind() {
215 return $this->kind;
216 }
217 public function setOutputLabel($outputLabel) {
218 $this->outputLabel = $outputLabel;
219 }
220 public function getOutputLabel() {
221 return $this->outputLabel;
222 }
223 public function setId($id) {
224 $this->id = $id;
225 }
226 public function getId() {
227 return $this->id;
228 }
229 public function setOutputMulti(/* array(OutputOutputMulti) */ $outputMulti) {
230 $this->assertIsArray($outputMulti, 'OutputOutputMulti', __METHOD__);
231 $this->outputMulti = $outputMulti;
232 }
233 public function getOutputMulti() {
234 return $this->outputMulti;
235 }
236 public function setOutputValue($outputValue) {
237 $this->outputValue = $outputValue;
238 }
239 public function getOutputValue() {
240 return $this->outputValue;
241 }
242 public function setSelfLink($selfLink) {
243 $this->selfLink = $selfLink;
244 }
245 public function getSelfLink() {
246 return $this->selfLink;
247 }
248 }
249
250 class OutputOutputMulti extends apiModel {
251 public $score;
252 public $label;
253 public function setScore($score) {
254 $this->score = $score;
255 }
256 public function getScore() {
257 return $this->score;
258 }
259 public function setLabel($label) {
260 $this->label = $label;
261 }
262 public function getLabel() {
263 return $this->label;
264 }
265 }
266
267 class Training extends apiModel {
268 public $kind;
269 public $storageDataLocation;
270 protected $__dataAnalysisType = 'TrainingDataAnalysis';
271 protected $__dataAnalysisDataType = '';
272 public $dataAnalysis;
273 public $trainingStatus;
274 protected $__modelInfoType = 'TrainingModelInfo';
275 protected $__modelInfoDataType = '';
276 public $modelInfo;
277 public $storagePMMLLocation;
278 public $id;
279 public $selfLink;
280 public $utility;
281 public function setKind($kind) {
282 $this->kind = $kind;
283 }
284 public function getKind() {
285 return $this->kind;
286 }
287 public function setStorageDataLocation($storageDataLocation) {
288 $this->storageDataLocation = $storageDataLocation;
289 }
290 public function getStorageDataLocation() {
291 return $this->storageDataLocation;
292 }
293 public function setDataAnalysis(TrainingDataAnalysis $dataAnalysis) {
294 $this->dataAnalysis = $dataAnalysis;
295 }
296 public function getDataAnalysis() {
297 return $this->dataAnalysis;
298 }
299 public function setTrainingStatus($trainingStatus) {
300 $this->trainingStatus = $trainingStatus;
301 }
302 public function getTrainingStatus() {
303 return $this->trainingStatus;
304 }
305 public function setModelInfo(TrainingModelInfo $modelInfo) {
306 $this->modelInfo = $modelInfo;
307 }
308 public function getModelInfo() {
309 return $this->modelInfo;
310 }
311 public function setStoragePMMLLocation($storagePMMLLocation) {
312 $this->storagePMMLLocation = $storagePMMLLocation;
313 }
314 public function getStoragePMMLLocation() {
315 return $this->storagePMMLLocation;
316 }
317 public function setId($id) {
318 $this->id = $id;
319 }
320 public function getId() {
321 return $this->id;
322 }
323 public function setSelfLink($selfLink) {
324 $this->selfLink = $selfLink;
325 }
326 public function getSelfLink() {
327 return $this->selfLink;
328 }
329 public function setUtility(/* array(double) */ $utility) {
330 $this->assertIsArray($utility, 'double', __METHOD__);
331 $this->utility = $utility;
332 }
333 public function getUtility() {
334 return $this->utility;
335 }
336 }
337
338 class TrainingDataAnalysis extends apiModel {
339 public $warnings;
340 public function setWarnings(/* array(string) */ $warnings) {
341 $this->assertIsArray($warnings, 'string', __METHOD__);
342 $this->warnings = $warnings;
343 }
344 public function getWarnings() {
345 return $this->warnings;
346 }
347 }
348
349 class TrainingModelInfo extends apiModel {
350 public $confusionMatrixRowTotals;
351 public $numberLabels;
352 public $confusionMatrix;
353 public $meanSquaredError;
354 public $modelType;
355 public $numberInstances;
356 public $classWeightedAccuracy;
357 public $classificationAccuracy;
358 public function setConfusionMatrixRowTotals($confusionMatrixRowTotals) {
359 $this->confusionMatrixRowTotals = $confusionMatrixRowTotals;
360 }
361 public function getConfusionMatrixRowTotals() {
362 return $this->confusionMatrixRowTotals;
363 }
364 public function setNumberLabels($numberLabels) {
365 $this->numberLabels = $numberLabels;
366 }
367 public function getNumberLabels() {
368 return $this->numberLabels;
369 }
370 public function setConfusionMatrix($confusionMatrix) {
371 $this->confusionMatrix = $confusionMatrix;
372 }
373 public function getConfusionMatrix() {
374 return $this->confusionMatrix;
375 }
376 public function setMeanSquaredError($meanSquaredError) {
377 $this->meanSquaredError = $meanSquaredError;
378 }
379 public function getMeanSquaredError() {
380 return $this->meanSquaredError;
381 }
382 public function setModelType($modelType) {
383 $this->modelType = $modelType;
384 }
385 public function getModelType() {
386 return $this->modelType;
387 }
388 public function setNumberInstances($numberInstances) {
389 $this->numberInstances = $numberInstances;
390 }
391 public function getNumberInstances() {
392 return $this->numberInstances;
393 }
394 public function setClassWeightedAccuracy($classWeightedAccuracy) {
395 $this->classWeightedAccuracy = $classWeightedAccuracy;
396 }
397 public function getClassWeightedAccuracy() {
398 return $this->classWeightedAccuracy;
399 }
400 public function setClassificationAccuracy($classificationAccuracy) {
401 $this->classificationAccuracy = $classificationAccuracy;
402 }
403 public function getClassificationAccuracy() {
404 return $this->classificationAccuracy;
405 }
406 }
407
408 class Update extends apiModel {
409 public $csvInstance;
410 public $label;
411 public function setCsvInstance(/* array(object) */ $csvInstance) {
412 $this->assertIsArray($csvInstance, 'object', __METHOD__);
413 $this->csvInstance = $csvInstance;
414 }
415 public function getCsvInstance() {
416 return $this->csvInstance;
417 }
418 public function setLabel($label) {
419 $this->label = $label;
420 }
421 public function getLabel() {
422 return $this->label;
423 }
424 }
425