PredictionIO / template-scala-parallel-universal-recommendation

PredictiionIO Template for Universal Recommender
111 stars 48 forks source link

Filtering is not working as expected #57

Open FouadWahabi opened 7 years ago

FouadWahabi commented 7 years ago

Please I'm getting some trouble with filtering. This is the format of #items I register :

{
  event: "like",
  entityType:"item",
  entityId:"583c7e85fe95435c679339a6",
  properties: {
    city : ["583c7e85fe95435c679835b0"],
    categories: ["583c7e85fe95435c6708a5b1"]
  }
}

Now I want to get the recommended items with filtering on the properties city and categories. This is the query I send :

curl -k -H "Content-Type: application/json"  -d '
{
"num": 250,
"fields": [{
"name": "city",
"values": ["583c7e85fe95435c679835b0"],
"bias": -1
}]
}' https://localhost:8000/queries.json

As you can see I set the value of the bias to -1 (a negative value to filter based on this field). I got correct response but what is wrong is the number of recommended items is too low (got only 20) compared to the result when don't using filtering (given that all the items I entered are having the same value for the property city) so what's supposed to be is to return the same list of items like when don't use filtering.

sanosay commented 7 years ago

I had same problem actually yesterday. Solved by reading docs more close. You need to set the properties via a "$set" request Example

{
    "event" : "$set",
    "entityType" : "item",
    "entityId" : "ipad",
    "properties" : {
        "category": ["electronics", "mobile-phones"],
        "expireDate": "2016-10-05T21:02:49.228Z",
        "availableDate": "2015-10-05T21:02:49.228Z"
    },
    "eventTime" : "2015-10-05T21:02:49.228Z"
}

In your case I assume it should be something like

{
    "event" : "$set",
    "entityType" : "item",
    "entityId" : "583c7e85fe95435c679339a6",
    "properties" : {
        "city" : ["583c7e85fe95435c679835b0"],
        "categories": ["583c7e85fe95435c6708a5b1"]
    }
}

You can always check your data assuming http://localhost:7070/events.json?accessKey=$ACCESS_KEY Be aware that those properties will be available after training as they are stored in Elasticsearch

This question was answered already [maybe not clear enough for lazy readers like me:P] on issue #48