From 729c8c58d519c8671d4268df895373f780732c47 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 13 Mar 2016 18:43:03 -0400 Subject: [PATCH 1/3] 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 --- test/prediction/model.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/prediction/model.js b/test/prediction/model.js index 6e65b324171..48add95d8cd 100644 --- a/test/prediction/model.js +++ b/test/prediction/model.js @@ -459,6 +459,7 @@ describe('Index', function() { }); delete apiResponseWithValue.outputLabel; + delete apiResponseWithValue.outputMulti; model.request = function(reqOpts, callback) { callback(null, apiResponseWithValue); From 34f6b12b4d45a267d6b86112c72cf19aa68e2841 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 13 Mar 2016 18:47:03 -0400 Subject: [PATCH 2/3] 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. --- lib/prediction/model.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/prediction/model.js b/lib/prediction/model.js index ebb6bc90e77..758c2b623ec 100644 --- a/lib/prediction/model.js +++ b/lib/prediction/model.js @@ -347,7 +347,10 @@ Model.prototype.query = function(input, callback) { var results = { winner: resp.outputLabel || resp.outputValue, - scores: resp.outputMulti + }; + + if (resp.outputMulti){ + results.scores = resp.outputMulti .sort(function(a, b) { return a.score < b.score ? 1 : a.score > b.score ? -1 : 0; }) From 7920dc7984cbbbcf4870a0ea5a91309396407f70 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 13 Mar 2016 19:18:33 -0400 Subject: [PATCH 3/3] Added name to authors/contributors as per [contributing guidelines](https://github.com/GoogleCloudPlatform/gcloud-node/blob/master/CONTRIBUTING.md) --- AUTHORS | 1 + CONTRIBUTORS | 1 + 2 files changed, 2 insertions(+) diff --git a/AUTHORS b/AUTHORS index 4f1a9fdc3fc..7ac622c350e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -8,3 +8,4 @@ Google Inc. Anand Suresh +Brett Bergmann diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9e8cf519004..ed19363b12a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,6 +12,7 @@ # Keep the list alphabetically sorted. Burcu Dogan +Brett Bergmann Johan Euphrosine Marco Ziccardi Patrick Costello