Menu

UPA

Stephan Zavrel

Before you start using the User Profile Aggregator plugin you need to store meta data for items in easyrec. To understand how the profile system works, please read the Profile System page first. It explains the basic concepts and APIs you need to know to successfully use the UPA.

Once you have integrated the profile API calls into your (commerce) system, it is time to use the additional information.

The user profile aggregator plugion (UPA)

easyrec comes with a plugin to aggregate the meta data stored with items and sent along with actions into a user profile. This user profile can be helpful to get a better understanding about a user's interesets and then further used to retrieve and improve recommendations for user. The plugin is called the user profile aggregator (UPA) and works by counting properties of the items a user performed actions on. Furthermore it can count the occurences of certain properties sent along in the actioninfo parameter with action calls. Which properties will be counted can be configured using the appropriate paramters in the easyrec admin gui. The resulting counts are then stored in the easyrec database as a user profile, i. e. an item of type "USER" with the userid used as id. If no profile for a user exists it will automatically created. Please note that user profiles are just a special type of item, therefore after successfully running the UPA plugin a lot of "USER" items will show up in the "Items&Rules" section. And since a user profile is also an item the profile API calls can conveniently be used to access any properties of a user's profile or to add custom fields.

The UPA plugin provides the following paramters for configuration (Note: some parameters use JSONPath notation to specifiy the fields of a JSON structure. If you are unfamiliar with JSONPath please refer to our introduction to JSONPath):

  • action type: Defines the type of actions to be considered for aggeregation of a user profile. If not defined, actions of all types are considered.
  • action info fields: The JSON fields in the actionInfo to be analysed. Use the following format: targetField,sourceJSONPath,(itemType),(threshold);itemType and threshold are optional: if not provided items of all types are considered. Use semicolon to define multiple fields for analysis. Example: genres,$.genre,MOVIE,3; tries to read the field$.genre from the actionInfo where the item type is MOVIE and writes the result to the field genres in the result profile. At least 3 (threshold) counts of the specific genre are needed to be stored in the profile.
  • do delta update: If true, only users with actions since the last plugin run are considered and the profiles updated accordingly.
  • item profile fields: The JSON fields in the item profile to be analysed. Use the following format: targetField,sourceJSONPath,(itemType), (threshold);itemType and threshold are optional: if not provided items of all types are considered. Use semicolon to define multiple fields for analysis. Example: genres,$.genre,MOVIE,3; tries to read the field $.genre from the item profile where the item type is MOVIE and writes the result to the field genres in the result profile. At least 3 (threshold) counts of the specific genre are needed to be stored in the profile.

Let us look at an example:

Assume we have items in the database that have profiles that look like this:

id: 1
type: MOVIE
description: The Terminator
profile:
{
    genres: ["Action", "Noir"]
    year: 1984
}

id: 2
type: MOVIE
description: Terminator 2 - Judgement Day
profile:
{
    genre: ["Action", "Scifi"]
    year: 1991
}

id: 3
type: MOVIE
description: The Godfather
profile:
{
    genre: ["Crime", "Drama"]
    year: 1972
}

Now assume further that a user John Doe bought those movies from a streaming service and thus we have the three buy actions:

actiontype-BUY,item-1,itemtype-MOVIE, actioninfo: {quality: HD}
actiontype-BUY,item-2,itemtype-MOVIE, actioninfo: {quality: HD}
actiontype-BUY,item-3,itemtype-MOVIE, actioninfo: {quality: SD}

Now given the information above we can configure the UPA plugin to aggregate a user profile for John Doe. So we will use the following configuration:

  • action type:
  • do delta update: true
  • action info fields:quality, $.quality;
  • item profile fields: genres, $.genre;

So using the above configuration the profile generated for user John Doe will look like this:

{
  "upa" : {
    "genres" : [ {
      "key" : "Action",
      "value" : 2
    }, {
      "key" : "Drama",
      "value" : 1
    }, {
      "key" : "TechNoir",
      "value" : 1
    }, {
      "key" : "Crime",
      "value" : 1
    }, {
      "key" : "Scifi",
      "value" : 1
    } ],
    "quality" : [ {
      "key" : "HD",
      "value" : 2
    }, {
      "key" : "SD",
      "value" : 1
    } ]
  }
}

As you can see the generated profile shows detailed counts of the genres of movies John Doe watched as well as which quality he used for streaming. So in our very small example we could deduce that John Doe likes to stream Action movies and prefers HD quality. This information can be used as a basis for other recommendation algorithms to provide personalized recommendations to user John Doe.

Just to demonstrate the flexibility of the plugin, lets assume that the first gerne in the genres list for each movie is the main genre and we are only interested in main genres. So we can simply change the configuration item profile fields to: genres,$.genres[0]; and the resulting user profile looks as follows:

{
  "upa" : {
    "genres" : [ {
      "key" : "Action",
      "value" : 2
    }, {
      "key" : "Crime",
      "value" : 1
    } ],
    "quality" : [ {
      "key" : "HD",
      "value" : 2
    }, {
      "key" : "SD",
      "value" : 1
    } ]
  }
}

Finally, let's look at more advanced features of the plugin like threshold with yet another configuration.


Related

Wiki: Home
Wiki: Profile System

MongoDB Logo MongoDB