简体   繁体   English

AQL 和图遍历:产品推荐示例

[英]AQL and Graph Traversal: Product recommendation example

I have been learning Arangodb and graph traversal using AQL, and I have looked at some of the examples that can be found online like flight paths, actors and movies, but I have trouble wrapping my head around writing what I initially thought would be a simple product recommendation experiment where a customer is recommended products he/she has not bought based on other customers' (who have made similar purchases) purchases.我一直在学习 Arangodb 和使用 AQL 的图形遍历,我也看过一些可以在网上找到的例子,比如飞行路径、演员和电影,但我无法全神贯注地写出我最初认为会很简单的东西产品推荐实验,根据其他客户(进行过类似购买)的购买,向客户推荐他/她未购买的产品。

This is what I managed to achieved to so far, retrieving products that other customers' who have purchased the same product as the current customer到目前为止,这是我设法实现的目标,检索与当前客户购买了相同产品的其他客户的产品

FOR products IN 1..1 OUTBOUND 'customers/118685' bought
    FILTER products._id LIKE "products/%" 
    FOR other_buyers IN 1..1 INBOUND products bought
    FILTER other_buyers._id != 'customers/118685' 
    FOR other_buyers_products IN 1..1 OUTBOUND other_buyers bought
    return other_buyers_products

Also, I haven't reached the stage where the recommendation would could be refined to customers who have made more similar purchases (ie based on higher count) with the current customer.此外,我还没有达到可以将推荐细化到与当前客户进行过更多类似购买(即基于更高计数)的客户的阶段。 Appreciate advice or helpful examples.感谢建议或有用的例子。

this is a very open question.这是一个非常开放的问题。 a more precise question would result in more and better answers... but i will give it a try.一个更精确的问题会导致更多更好的答案......但我会试一试。

you can express your current query in a more condense way:您可以以更简洁的方式表达您当前的查询:

FOR product IN 3..3 ANY 'customers/1' purchases
RETURN DISTINCT product

counting occurrences of a product can be added easely with COLLECT :可以使用COLLECT轻松添加计算产品的出现次数:

FOR product IN 3..3 ANY 'customers/1' purchases
COLLECT pid = product._id WITH COUNT INTO count
RETURN { pid, count }

this is still a very naive approach.这仍然是一种非常幼稚的做法。 you will end up with recommendations like "you once bought banana, you should by toilet paper", because everybody bought those things eventually.你最终会得到像“你曾经买过香蕉,你应该用卫生纸”这样的建议,因为每个人最终都会买那些东西。 you can improve your results by not just saving what product a customer bought, but also when.您不仅可以保存客户购买的产品,还可以保存购买时间,从而改善结果。 Then you will be able to find out what products are bought together often, fe a flashlight and batteries.然后您将能够找出经常一起购买的产品,例如手电筒和电池。

look around on the inte.net for further inspiration, fe here .在 inte.net 上四处寻找更多灵感,请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM