0

I need to get user-based recommendations with graphaware and I don't know how to do that. As far as I can see, all I seem to get from graphaware's neo4j-reco are item-similarities as in 'people who bought a also bought b'. But what I'm interested in is user-based recommendations like 'recommended for you, based on your previous purchases'. Any idea how to do that?

Bernd Hopp
  • 75
  • 7
  • I'm kind of curious, how do you see such a system working, if it's not referencing what others have bought who have bought the same things you have? If the only info it's referencing is your own, what can it really recommend you besides what you've bought previously? – InverseFalcon Nov 27 '16 at 20:47
  • I guess you could recommend other products from the same manufacturer, or similar products from other manufacturers. That should be easy enough to do with Neo4j alone, though you'll need your graph to track the types of items as well as well as manufacturers. Still, that's a big pool of recommendations, which is why having info to supplement this is useful, such as items that others have bought who have made similar purchases to yours. – InverseFalcon Nov 27 '16 at 20:56
  • hm, let me try to clarify. The README.md of neo4j-reco gives an example of a 'FriendsComputingEngine' where I could compute people that I likely know because we share some common friends. What I wonder is: If we had two entities, users and items and every user could 'like' several items, how would I get recommendations for a specific user, based on the items he already 'likes'. – Bernd Hopp Nov 27 '16 at 21:10
  • The basis of the FriendsComputingEngine is finding friends in common, with the more friends in common meaning a stronger match. The "people who bought a also bought b" approach is similar, finding people with similar shopping habits, who have bought or like the same kinds of items (more in common is likely a stronger recommendation), and then finding other things they liked or bought that could be recommended to you. I previously mentioned querying for other items from the same manufacturer, or items of the same type. If you have a robust tagging system in place, then that can help too. – InverseFalcon Nov 27 '16 at 21:27
  • I'm not clear whether you're looking for ideas on what logic to use, or you know the logic and just wonder how to implement it using GraphAware Reco. So my question to you: would you be able to express your "user-based" recommendation logic using a Cypher query? – Michal Bachman Nov 28 '16 at 07:56

1 Answers1

4

GraphAware-Reco is mainly a skeleton helping you build enterprise-grade recommendation engines atop a neo4j database.

This means that it provides base classes and an architecture that you need to extend yourself with your own logic.

If you take your requirements, here purchase history, a very naive approach to get started with is for example to find the characteristics of the products purchased.

Lets say user 1 purchased an iphone and an ipad, that can have those characteristics :

iphone brand : apple, category: electronics
ipad brand: apple, category: electronics

You can create a first engine that will match potential candidates based on those characteristics, this engine will extend the CypherEngine with the following query :

MATCH (n:User {id: 111})-[:PURCHASED]->(product)
WITH distinct product
MATCH (product)-[:HAS_CHARACTERISTIC]->(c)<-[:HAS_CHARACTERISTIC]-(reco)
RETURN reco, count(*) AS score

Another approach you can combine with this one is to find people having bought the same items as the user and find what they also bought, you will then create another engine with the following query :

MATCH (n:User {id: 111})-[:PURCHASED]->(product)
WITH distinct product, user
MATCH (product)<-[:PURCHASED]-(collab)
WHERE collab <> user
MATCH (collab)-[:PURCHASED]->(reco)
RETURN reco, count(*) AS score

When using those two engines, GraphAware Reco will automatically combine the scores from each engine into one.

You can find an example of a CypherEngine in the tests : https://github.com/graphaware/neo4j-reco/blob/master/src/test/java/com/graphaware/reco/neo4j/engine/CypherEngineTest.java

You can also add a blacklist for not recommending items the user already bought.

As I said, this is a first step, if you have a big catalog with lot of purchases, you might consider doing background computations (for eg, similarity between products and only relate top k-nn products between them and same for purchases and related similar users between them)

GraphAware-Reco offers you facilities for having background computation jobs and GraphAware-Reco-Enterprise comes with pre-defined algorithms for the similarity computations between items as well as an Apache Spark integration for moving the similarity computation process outside of the neo4j jvm and write back the results/relationships to neo4j (not open-sourced)

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36