predictionio-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shane Johnson <shanewaldenjohn...@gmail.com>
Subject Passing an array of objects to get predictions?
Date Fri, 16 Jun 2017 14:35:06 GMT
Has anyone extended PredictionIO to handle an array of objects instead of
Posting a single object to get individual scores.

For example if I post this to localhost:8000/queries.json

{
   "AccountId": "0016A000001vxxxxx",
"OpportunityId": "0066A000001xxxxxx",
"NaicsCode": 518420,
   "AnnualRevenue": 100000000,
   "NumberOfEmployees": 10000,
   "BillingState": "Virginia",
   "BillingCountry": "United States"
}

I get the expected response of

{
  "score": 0.7110000252723694
}

but when I post this

[
{
   "AccountId": "0016A000001vxxxxx",
"OpportunityId": "0066A000001xxxxxx",
"NaicsCode": 518420,
   "AnnualRevenue": 100000000,
   "NumberOfEmployees": 10000,
   "BillingState": "Virginia",
   "BillingCountry": "United States"
},
{
"AccountId": "0045H000001xxxxxx",
"OpportunityId": "0088A000001exxxxx",
"NaicsCode": 518420,
   "AnnualRevenue": 100000000,
   "NumberOfEmployees": 10000,
   "BillingState": "Virginia",
   "BillingCountry": "United States"
}
]

I get the following error.

Query:
[
...
]

Stack Trace:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)


I expected to get the error but am hoping someone could point me in the
right direction on where to extend the Scala code to interpret an Array of
Objects into the Query object and then return multiple scores.

Thanks in advance if anyone has worked on this.

*Shane Johnson | 801.360.3350*
LinkedIn <https://www.linkedin.com/in/shanewjohnson> | Facebook
<https://www.facebook.com/shane.johnson.71653>

Mime
View raw message