Filtering and Boosting

Filtering

In filtering, the expression must return boolean value for each item. If the returned value is true, the item passed the filter; if the value is false, the item does not pass and will be discarded. The value is computed from set property values of the individual items. You can access value of a property by putting name of the property into the single quotes.

Consider the following table of items in sample movie-recommendation domain:

Name: string Year:int Genres: set Parental-Advisory:boolean
Pulp Fiction 1994
{“Crime Fiction”,”Drama”
“Thriller” }
true
The Matrix 1999
{“Science Fiction”,”Action”,
“Adventure” }
false
Fight Club 1999
{“Drama”, “Existentialism”}
true
The Lord of the Rings: The Return of the King 2003
{ “Adventure”, “Fantasy”,
“Action” }
false
The Dark Knight 2008
{“Superhero”,”Drama”
,”Action”,”Adventure”,
“Thriller”,”Crime Fiction”}
false
Silence of the Lambs 1991
{“Crime Fiction”, “Drama”,
“Thriller”, “Horror” }
true
American Beauty 1999
{ “Romance”, “Comedy”,
“Drama”, “Satire”,
“Existentialism” }
true
... and 10000 other movies

By default, when items are to be recommended to a given user, the recommender selects any items which seem relevant to the user. However, it may be your policy not to recommend items with Parental-Advisory flag set on. Hence you may use the following simple ReQL filtering expression:

not 'Parental-Advisory'

Then the recommender may only choose one of the following movies:

Name: string Year:int Genres: set Parental-Advisory:boolean
The Matrix 1999
{“Science Fiction”,”Action”,
“Adventure” }
false
The Lord of the Rings: The Return of the King 2003
{ “Adventure”, “Fantasy”,
“Action” }
false
The Dark Knight 2008
{“Superhero”,”Drama”
,”Action”,”Adventure”,
“Thriller”,”Crime Fiction”}
false
... and 5926 others

As another example, consider that user entered the “Drama” section of your system’s catalog. Then you sure wish to recommend dramas, ignoring the fact that usually, the user likes comedies. You may do this using another ReQL filtering expression:

"Drama" in 'Genres'

Note that strings are enclosed in double quotes.

Then only the following items will pass the filter:

Name: string Year:int Genres: set Parental-Advisory:boolean
Pulp Fiction 1994
{“Crime Fiction”,”Drama”
“Thriller” }
true
Fight Club 1999
{ “Drama”, “Existentialism” }
true
The Dark Knight 2008
{“Superhero”,”Drama”
,”Action”,”Adventure”,
“Thriller”,”Crime Fiction”}
false
Silence of the Lambs 1991
{“Crime Fiction”, “Drama”,
“Thriller”, “Horror” }
true
American Beauty 1999
{ “Romance”, “Comedy”,
“Drama”, “Satire”,
“Existentialism” }
true
... and 3141 other movies

Handling deleted items

Filtering offers you an elegant way of handling deleted/obsolete items in the catalog. In many situations, it may happen that some items become unavailable and hence should not be recommended anymore. Considering interaction data, however, such items may still be important for the recommender. For example, the recommender may find out that users who liked a no more available item, x, will probably like another item, y, which is still actual. Therefore, it is undesirable to simply delete x, deleting also all the related interactions in cascade.

With filtering, you may handle item deletes using the following scheme:
  • Create a dedicated item property, such as deleted, of type boolean (the implicit value for all items will be null, which is OK).
  • For deleted items, set the value of deleted true.
  • For recommendations, use the following filter:
not 'deleted'
  • Occasionally, if the item becomes available again, you may set deleted false.

Such a mechanism cay easily be extended to control availability over different regions, customer licenses, etc.

Boosting

In advanced applications, besides filtering, you may wish to boost recommendation rates of some items. In contrast to filtering, where items may be completely blocked, in boosting, you may tell the recommender to prefer some items among others. Indeed, by default, it is a task of the recommender itself to select the items which are the most relevant. However, it may be your policy to purposefully bias the recommender toward your business goals.

For example, considering the above table of movies, one may wish to promote the movies which are new and were filmed after 2000, especially if they were filmed after 2005. Then the following boosting query can handle that:

if 'Year' <= 2000 then 1 else (if 'Year' <= 2005 then 1.5 else 2)

As you can see, boosting expressions return numbers rather than booleans as in case of filtering. Specifically, they provide the items with coefficients by which the internal scores determined by the recommender will be multiplied.

The boosting coefficients assigned by the query are shown in the following table:

Name: string Year:int Genres: set Parental-Advisory:boolean Boosting
Pulp Fiction 1994
{“Crime Fiction”,”Drama”
“Thriller” }
true 1.0
The Matrix 1999
{“Science Fiction”,”Action”,
“Adventure” }
false 1.0
Fight Club 1999
{ “Drama”, “Existentialism” }
true 1.0
The Lord of the Rings: The Return of the King 2003
{ “Adventure”, “Fantasy”,
“Action” }
false 1.5
The Dark Knight 2008
{“Superhero”,”Drama”
,”Action”,”Adventure”,
“Thriller”,”Crime Fiction”}
false 2.0
Silence of the Lambs 1991
{“Crime Fiction”, “Drama”,
“Thriller”, “Horror” }
true 1.0
American Beauty 1999
{ “Romance”, “Comedy”,
“Drama”, “Satire”,
“Existentialism” }
true 1.0
... and 10000 other movies