ArangoDB - Graph based recommender system

627 Views Asked by At

I am using ArangoDB and I am trying to build a graph-based recommender system with it.

The data model just contains users, items and ratings (edges).

Therefore want to calculate the affinity of a user to a movie with the katz measure.

Eventually I want to do this:

Get all (or a certain number of) paths between a user and a item
For all of these paths do the following:
  Multiply each edge's rating with a damping factor (e.g. 0.7)
  Sum up all calculated values within a path
Calculate the average of all calculated path values

The result is some kind of affinity between a user and an item, weighted with the intermediary ratings and damped by a defined factor.

I was trying to realize something like that in AQL but it was either wrong or much too slow. How could a algorithm like this look in AQL?

From a performance point of view there might be better choices for graph based recommender systems. If someone has a suggestion (e.g. Item Rank or other algorithms), it would also be nice to get some ideas here.

I love this topic but sometimes I get to my borders.

1

There are 1 best solutions below

0
On

In the following, @start and @end are parameters representing the two endpoints; for simplicity, I've assumed that:

  1. the maximum admissible path length is 10000
  2. "rates" is the name of the "edges" collection
  3. "rating" is the name of the property giving a weight to an edge
  4. the "damping" factor is as per the requirements
FOR v,e,p IN 0..10000 OUTBOUND @start rates
    OPTIONS {uniqueVertices: "path"}
    FILTER v._id==@end
    LET r = AVERAGE(p.edges[*].rating) * 0.7
    COLLECT AGGREGATE avg = AVERAGE(r)
    RETURN  avg