predictionio-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Szeto <don...@apache.org>
Subject Re: Passing an array of objects to get predictions?
Date Fri, 16 Jun 2017 23:46:52 GMT
Yes they usually live in Engine.scala if you start from a template.

The Apache JIRA is open for public registration. Thanks for helping out!

On Fri, Jun 16, 2017 at 3:09 PM Shane Johnson <shanewaldenjohnson@gmail.com>
wrote:

> Thanks Pat and Donald!
>
> Donald, is the query class you are referring to in the Engine.scala or
> somewhere else. I am currently working in the Engine.scala file to try to
> accept an array of objects. Have you seen anyone do this or does anyone
> have some sample code to get me pointed in the right direction?
>
> Happy to file a feature request. How do I get access to JIRA?
>
> Best,
>
> Shane
>
> *Shane Johnson | 801.360.3350*
> LinkedIn <https://www.linkedin.com/in/shanewjohnson> | Facebook
> <https://www.facebook.com/shane.johnson.71653>
>
> On Fri, Jun 16, 2017 at 10:10 AM, Donald Szeto <donald@apache.org> wrote:
>
>> Hi Shane,
>>
>> Look for the query class that is part of the template (it is a type
>> parameter for the algorithm class). There you can customize your input
>> query to accept an array of objects, then modify the predict method in the
>> algorithm class to handle them.
>>
>> I believe this is getting asked more that might warrant a framework level
>> support. It would be great help if you could file a feature request on our
>> JIRA.
>>
>> Regards,
>> Donald
>>
>> On Fri, Jun 16, 2017 at 9:04 AM Pat Ferrel <pat@occamsmachete.com> wrote:
>>
>>> Arrays of events need to be posted to POST
>>> http://localhost:7070/batch/events.json?accessKey=… Notice the
>>> different URL. Look towards the bottom of this page:
>>> https://predictionio.incubator.apache.org/datacollection/eventmodel/
>>>
>>>
>>> On Jun 16, 2017, at 7:35 AM, Shane Johnson <shanewaldenjohnson@gmail.com>
>>> wrote:
>>>
>>> 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 <(801)%20360-3350>*
>>> LinkedIn <https://www.linkedin.com/in/shanewjohnson> | Facebook
>>> <https://www.facebook.com/shane.johnson.71653>
>>>
>>>
>

Mime
View raw message