davidcelis / recommendable

:+1::-1: A recommendation engine using Likes and Dislikes for your Ruby app
http://davidcelis.github.io/recommendable/
MIT License
1.36k stars 115 forks source link

User recommendation #110

Closed mbajur closed 9 years ago

mbajur commented 9 years ago

Hey! Please, tell me, is that possible to create a "People you may know" functionality using recommendable gem?

I decided to give it a try by using like as a following relation. Here is my environment:

image

# B follows C
user_b.like(user_c)

# D follows C
user_d.like(user_c)

# D follows E
user_d.like(user_e)

# The below does not behave as i want it to - there are no any suggestions 
# for user A after that.
#
# A follows B and D
user_a.like(user_b)
user_a.like(user_d)

What's wrong in here? I feel a bit lost in all that recommendation thing (that's probably third gem/tool i'm trying to use for that functionality and i'm still not able to do anything). Thanks in advance :)

davidcelis commented 9 years ago

Hi, @mbajur! Thanks for trying out my little gem. Recommendable should work really well for your usecase, and it seems like you already figured out how to do that. Using likes in replacement of follows is exactly what I would do too, and it should work great that way. My guess is that you aren't running a background processor like Sidekiq or Resque and also aren't manually updating your recommendation data. Recommendable ships with background workers for common processors like Sidekiq, Resque, and DelayedJob. If one of those processes is running actively, it should just work and refresh recommendations when a user submits a new like.

If you're just playing around locally, you can update your recommendation data like this:

User.all.each do |user|
  Recommendable::Helpers::Calculations.update_similarities_for(user.id)
  Recommendable::Helpers::Calculations.update_recommendations_for(user.id)
end

Could you try that and then let me know if user_a gets any suggestions?

mbajur commented 9 years ago

I have removed that code few minutes ago but i'm gonna recreate it tomorrow and let you know if that helped. Anyway - i have a recommendable sidekiq queue and i can see that there are some workers running when i'm liking stuff - is that enough?

davidcelis commented 9 years ago

That should be enough, yeah. I'd still suggest running that above code manually just in case and let me know if that doesn't help.

mbajur commented 9 years ago

Ok i decided to recreate it now. I have run that code you provided and the output is the same with and without it - the only recommendation i can get in my whole environment and when user_A likes ONLY user_B (first scenario from What i'm trying to achieve) is that user_b.recommended_users returns user_E as a recommendation. Running recommended_users on any other user (including A) returns []

davidcelis commented 9 years ago

Oh actually, that makes sense. Sorry, I misunderstood the original situation. Recommendable doesn't really do the sort of recommendation logic you're talking about, it's all collaborative filtering. So it makes sense that the only recommendation is User E being recommended to User B. The reason for that is that both User B and User D follow User C. That increases the similarity between User B and User D, so User D's other like (User E) is recommended to User B. Does that make sense?

mbajur commented 9 years ago

yeah, that totally makes sense :) too bad such scenario is not supported. I'm gonna continue my search for such thing. Big thanks for your help! :)