Skip to content

Commit 63f6586

Browse files
savethefailsstephenplusplus
authored andcommitted
Changed test "query success should return the outputValue as the winner" to match the expected prediction#output response returned by Trainedmodels: predict for Regression models. prediction#output response for Regression models does not contain an outputMulti response
Removed 'scores' from returned results of prediction/model#query when returning a `prediction#output` response from Trainedmodels:predict for Regression models. Trainedmodels:predict response for Regression models does not contain `outputMulti` so no scores should be calculated. Added name to authors/contributors as per [contributing guidelines](https://github.com/GoogleCloudPlatform/gcloud-node/blob/master/CONTRIBUTING.md)
1 parent 862f836 commit 63f6586

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88

99
Google Inc.
1010
Anand Suresh
11+
Brett Bergmann

CONTRIBUTORS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
# Keep the list alphabetically sorted.
1313

14+
Anand Suresh <[email protected]>
15+
Brett Bergmann <[email protected]>
1416
Burcu Dogan <[email protected]>
17+
Hector Rovira <[email protected]>
1518
Johan Euphrosine <[email protected]>
1619
Marco Ziccardi <[email protected]>
1720
Patrick Costello <[email protected]>
1821
Silvano Luciani <[email protected]>
1922
Stephen Sawchuk <[email protected]>
20-
Anand Suresh <[email protected]>
21-
Hector Rovira <[email protected]>

lib/prediction/model.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,18 @@ Model.prototype.query = function(input, callback) {
347347

348348
var results = {
349349
winner: resp.outputLabel || resp.outputValue,
350-
scores: resp.outputMulti
350+
};
351+
352+
if (resp.outputMulti) {
353+
results.scores = resp.outputMulti
351354
.sort(function(a, b) {
352355
return a.score < b.score ? 1 : a.score > b.score ? -1 : 0;
353356
})
354357
.map(function(scoreObject) {
355358
scoreObject.score = parseFloat(scoreObject.score);
356359
return scoreObject;
357-
})
358-
};
360+
});
361+
}
359362

360363
callback(null, results, resp);
361364
});

test/prediction/model.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ describe('Index', function() {
459459
});
460460

461461
delete apiResponseWithValue.outputLabel;
462+
delete apiResponseWithValue.outputMulti;
462463

463464
model.request = function(reqOpts, callback) {
464465
callback(null, apiResponseWithValue);

0 commit comments

Comments
 (0)