You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@predictionio.apache.org by Pat Ferrel <pa...@occamsmachete.com> on 2018/07/06 20:15:46 UTC

Re: [actionml/universal-recommender] Boosting categories only shows one category type (#55)

Please read the docs. There is no need to $set users since they are
attached to usage events and can be detected automatically. In fact
"$set"ting them is ignored. There are no properties of users that are not
calculated based on named “indicators’, which can be profile type things.

Fot this application I’d ask myself what you want the user to do? Do you
want them to view a house listing or schedule a visit? Clearly you want
them to rent but there will only be one rent per user so it is not very
strong for indicating taste.

If you have something like 10 visits per user on average you may have
enough to use as the primary indicator since visits are closer to “rent”,
intuitively, Page views, which may be 10x - 100x more than visits are your
last resort. But if page views is the best “primary” indicators you have,
still use visits and rents as secondary. Users have many motivations for
looking at listing and they may be only to look at higher priced units that
they have any intent of renting or to compare something they would not rent
to what they would. Therefor page views are somewhat removed from the pure
user intent of every “rent” but they may be the best indicator you have.

Also consider using things like search terms as secondary indicators.

Then send primary and all secondary events with whatever ids correspond to
the event type. User profile data is harder to use and not a useful as
people think but is still encoded as an indicator but with different
“eventName”. Something like “location” could be used and might have and id
like a postal code—something that is large enough to include other users
but small enough to be exclusive also.

The above will give you several “usage events” with one primary.

Business rule—which are used to restrict results—require you to $set
properties for every rental. So anything in the fields part of a query must
correspond to a possible property of items. Those look ok below.

Please use the Google group for questions. Github is for bug reports.


From: Amit Assaraf <no...@github.com> <no...@github.com>
Reply: actionml/universal-recommender
<re...@reply.github.com>
<re...@reply.github.com>
Date: July 6, 2018 at 10:11:10 AM
To: actionml/universal-recommender
<un...@noreply.github.com>
<un...@noreply.github.com>
Cc: Subscribed <su...@noreply.github.com>
<su...@noreply.github.com>
Subject:  [actionml/universal-recommender] Boosting categories only shows
one category type (#55)

I have an app that uses Universal Recommender. The app is an app for
finding a house for rent.
I want to recommend users houses based on houses they viewed or scheduled a
tour on already.

I added all the users using the $set event.
I added all (96,676) the houses in the app like so:

predictionio_client.create_event(
                event="$set",
                entity_type="item",
                entity_id=listing.meta.id,
                properties={
                      "property_type": ["villa"] # There are many
types of property_types such as "apartment"
                }
            )

And I add the events of the house view & schedule like so:

predictionio_client.create_event(
            event="view",
            entity_type="user",
            entity_id=request.user.username,
            target_entity_type="item",
            target_entity_id=listing.meta.id
        )

Now I want to get predictions for my users based on the property_types they
like.
So I send a prediction query boosting the property_types they like using
Business Rules like so:

{
    'fields': [
        {
             'bias': 1.05,
             'values': ['single_family_home', 'private_house',
'villa', 'cottage'],
             'name': 'property_type'
        }
     ],
     'num': 15,
     'user': 'amit70'
}

Which I would then expect that I would get recommendations of different
types such as private_house or villa or cottage. But for some weird reason
while having over 95,000 houses of different property types I only get
recommendations of *ONE* single type (in this case villa) but if I remove
it from the list it just recommends 10 houses of ONE different type.
This is the response of the query:

{
    "itemScores": [
        {
            "item": "56.39233,-4.11707|villa|0",
            "score": 9.42542
        },
        {
            "item": "52.3288,1.68312|villa|0",
            "score": 9.42542
        },
        {
            "item": "55.898878,-4.617019|villa|0",
            "score": 8.531346
        },
        {
            "item": "55.90713,-3.27626|villa|0",
            "score": 8.531346
        },
.....

I cant understand why this is happening. The elasticsearch query this
translates to is this:
GET /recommender/_search

{
  "from": 0,
  "size": 15,
  "query": {
    "bool": {
      "should": [
        {
          "terms": {
            "schedule": [
              "32.1439352176,34.833260278|private_house|0",
              "31.7848439,35.2047335|apartment_for_sale|0"
            ]
          }
        },
        {
          "terms": {
            "view": [
              "32.0734919,34.7722675|garden_apartment|0",
              "32.1375986782,34.8415740159|apartment|0",
              "32.0774,34.8861|apartment_for_sale|0",
              "31.7720155609,35.1917438892|apartment|0",
               ..... (over 20 more)
            ]
          }
        },
        {
          "terms": {
            "property_type": [
              "single_family_home",
              "private_house",
              "villa",
              "cottage"
            ],
            "boost": 1.1
          }
        },
        {
          "constant_score": {
            "filter": {
              "match_all": {}
            },
            "boost": 0
          }
        }
      ],
      "must": [],
      "must_not": [
        {
          "ids": {
            "values": [
              "31.7848439,35.2047335|apartment_for_sale|0",
              "32.1439352176,34.833260278|private_house|0"
            ],
            "boost": 0
          }
        }
      ],
      "minimum_should_match": 1
    }
  },
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "popRank": {
        "unmapped_type": "double",
        "order": "desc"
      }
    }
  ]
}

Does anyone know why this is happening?
I only have 2 users using the app, the one I am querying with and another
one.

This is my engine.json:

{
  "id": "default",
  "description": "Default settings",
  "engineFactory": "com.actionml.RecommendationEngine",
  "datasource": {
    "params" : {
      "name": "houses-data.txt",
      "appName": "Houses",
      "eventNames": ["schedule", "view"],
      "eventWindow": {
         "duration": "3650 days",
         "removeDuplicates": false,
         "compressProperties": false
      }
    }
  },
  "sparkConf": {
    "spark.serializer": "org.apache.spark.serializer.KryoSerializer",
    "spark.kryo.registrator":
"org.apache.mahout.sparkbindings.io.MahoutKryoRegistrator",
    "spark.kryo.referenceTracking": "false",
    "spark.kryoserializer.buffer": "300m",
    "es.index.auto.create": "true"
  },
  "algorithms": [
    {
      "name": "ur",
      "params": {
        "appName": "Houses",
        "indexName": "recommender",
        "typeName": "items",
        "recsModel": "all",
        "backfillField": {
          "name": "popRank",
          "backfillType": "hot",
          "eventNames": ["schedule", "view"]
        },
        "rankings": [
          {
            "name": "popRank",
            "type": "popular",
            "eventNames": ["schedule", "view"]
          },
          {
            "name": "uniqueRank",
            "type": "random"
          },
          {
            "name": "preferredRank",
            "type": "userDefined"
          }
        ],
        "indicators": [
          {
             "name": "schedule"
          },
          {
             "name": "view",
             "maxCorrelatorsPerItem": 50,
             "minLLR": 5
          }
        ]
      }
    }
  ]
}

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/actionml/universal-recommender/issues/55>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAT8S9zdtJ8Cav5s-0F6akM0uiZcI7cqks5uD5ojgaJpZM4VFxVm>
.