Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boosting categories only shows one category type #55

Open
amitassaraf opened this issue Jul 6, 2018 · 1 comment
Open

Boosting categories only shows one category type #55

amitassaraf opened this issue Jul 6, 2018 · 1 comment

Comments

@amitassaraf
Copy link

amitassaraf commented Jul 6, 2018

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"
                      .... # there are more properties that I defined but I dont use such as "city", "price", "bedrooms", and more
                }
            )

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 other different type. While I want it to give me of all the different types.
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
	  }
	]
      }
    }
  ]
}
@pferrel
Copy link
Collaborator

pferrel commented Jul 6, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants