I was making a graph for a recommendation system and added vertices for users, categories and products and edges to represent the connections between them. One product may have connections to categories and a rating as a property for them. Users can also have a rating for each category. So, it is something like this:
-- User preferences.
SELECT * FROM cypher('RecommenderSystem', $$
MATCH (a:Person {name: 'Abigail'}), (A:Category), (C:Category), (H:Category)
WHERE A.name = 'A' AND C.name = 'C' AND H.name = 'H'
CREATE (a)-[:RATING {rating: 3}]->(C),
(a)-[:RATING {rating: 1}]->(A),
(a)-[:RATING {rating: 0}]->(H)
$$) AS (a agtype);
-- Products rating.
SELECT * FROM cypher('RecommenderSystem', $$
MATCH (product:Product {title: 'Product_Name'}), (A:Category), (C:Category), (H:Category)
WHERE A.name = 'A' AND C.name = 'C' AND H.name = 'H'
CREATE (product)-[:RATING {rating: 0}]->(C),
(product)-[:RATING {rating: 4}]->(A),
(product)-[:RATING {rating: 0}]->(H)
$$) AS (a agtype);
My recommendation system is based on Content Filtering, which uses information we know about people and products as connective tissue for recommendations. So for this, it would be necessary to do a calculation like: [(user_rating_C x product_rating_C) + (user_rating_A x product_rating_A) + (user_rating_H x product_rating_H)] / (num_categories x max_rating)
. For example, the likelihood of Abigail liking the product from the cypher query above would be:
[(3 x 0) + (1 x 4) + (0 x 0)] / (3 x 4) = 0.333 which in a range from 0 to 4, she is likely going to hate the product. And the closer to 4, the more likely becomes for the user to buy or consume the product.
But then, how could I retrieve every edge rating that is connected to a person and a product and do this type of calculation with it?