Hi there. I''ve been using acts_as_rateable on goneraw.com, which is written in rails. It works great, but there''s kind of a problem with the way it sorts ratings. Namely, if everyone adores a recipe, and it''s been rated two dozen times at five-stars, but someone has given it four stars, and you have another recipe with *one* rating of five stars... the recipe with a single five-star rating will always come out on top! I''ve been thinking a lot about this problem and don''t have a clean solution in mind. Here''s how I find the three favorite recipes (on the home page) now: @favorite_recipes = @recipes.sort { |a,b| b.rating <=> a.rating }[0...3] Well, it''s not trivial to fix this, is it? Does anyone have a better algorithm in mind, for weighting the ratings by how many ratings a particular item has received? This seems like a common problem for anyone using acts_as_rateable.... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Benjamin Curtis
2006-Nov-26 03:35 UTC
Re: acts_as_rateable implementation / algorithm question
Sometimes simple works... I don''t use the acts_as_rateable plugin, but for the ''Top Rated'' category at the plugin directory I simply sort by the rating times the number of votes. -- Building an e-commerce site with Rails? http://www.agilewebdevelopment.com/rails-ecommerce On Nov 25, 2006, at 11:31 AM, Raymond wrote:> > Hi there. I''ve been using acts_as_rateable on goneraw.com, which is > written in rails. It works great, but there''s kind of a problem with > the way it sorts ratings. Namely, if everyone adores a recipe, and > it''s > been rated two dozen times at five-stars, but someone has given it > four > stars, and you have another recipe with *one* rating of five stars... > the recipe with a single five-star rating will always come out on top! > > I''ve been thinking a lot about this problem and don''t have a clean > solution in mind. Here''s how I find the three favorite recipes (on the > home page) now: > > @favorite_recipes = @recipes.sort { |a,b| b.rating <=> a.rating > }[0...3] > > Well, it''s not trivial to fix this, is it? Does anyone have a better > algorithm in mind, for weighting the ratings by how many ratings a > particular item has received? This seems like a common problem for > anyone using acts_as_rateable.... > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Justin Forder
2006-Nov-26 19:22 UTC
Re: acts_as_rateable implementation / algorithm question
Benjamin Curtis wrote:> Sometimes simple works... I don''t use the acts_as_rateable plugin, > but for the ''Top Rated'' category at the plugin directory I simply > sort by the rating times the number of votes.Shouldn''t one star be treated as a negative review? I''d rather choose a product with ten reviews that all give five stars, than a product with a thousand one-star reviews! Justin Forder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It would seem that a simple adjustment to Ben''s system would be to slide the star ratings down by 3 before doing the calculation. Make 1 star => -2, 2 => -1, 3 => 0, 4 => 1, 5 => 2. Now, 1000 1 star reviews will actually bring the total rating down. You could adjust the weights to make 1 and 5 star ratings not be linear - 1 star => -5, 5 star => 5 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig Jolicoeur
2006-Dec-07 16:53 UTC
Re: acts_as_rateable implementation / algorithm question
Benjamin Curtis wrote:> Sometimes simple works... I don''t use the acts_as_rateable plugin, > but for the ''Top Rated'' category at the plugin directory I simply > sort by the rating times the number of votes. > > -- > Building an e-commerce site with Rails? > http://www.agilewebdevelopment.com/rails-ecommerceHow would this work? If I have an item with 20 votes all of 1 star that would equal 20*1 = 20 and If I have an item with 2 votes of 4 stars that would equal 2*4 = 8 so that item that had been with all 1-star votes would show up higher than the item with all 4-star votes. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Benjamin Curtis
2006-Dec-07 17:17 UTC
Re: acts_as_rateable implementation / algorithm question
On Dec 7, 2006, at 8:53 AM, Craig Jolicoeur wrote:> > Benjamin Curtis wrote: >> Sometimes simple works... I don''t use the acts_as_rateable plugin, >> but for the ''Top Rated'' category at the plugin directory I simply >> sort by the rating times the number of votes. >> > > How would this work? If I have an item with 20 votes all of 1 star > that > would equal 20*1 = 20 > > and If I have an item with 2 votes of 4 stars that would equal 2*4 = 8 > > so that item that had been with all 1-star votes would show up higher > than the item with all 4-star votes.Earlier in this thread Tom Fakes recommended an improvement to what I described that solves the problem you mention. Practically speaking, though, even my simplistic approach is suitable for the usage patterns of the plugin directory. -- Building an e-commerce site with Rails? http://www.agilewebdevelopment.com/rails-ecommerce --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2006-Dec-07 18:01 UTC
Re: acts_as_rateable implementation / algorithm question
> Benjamin Curtis wrote: >> Sometimes simple works... I don''t use the acts_as_rateable plugin, >> but for the ''Top Rated'' category at the plugin directory I simply >> sort by the rating times the number of votes. >> >> -- >> Building an e-commerce site with Rails? >> http://www.agilewebdevelopment.com/rails-ecommerce > > How would this work? If I have an item with 20 votes all of 1 star that > would equal 20*1 = 20 > > and If I have an item with 2 votes of 4 stars that would equal 2*4 = 8 > > so that item that had been with all 1-star votes would show up higher > than the item with all 4-star votes.You could modify things so when some rates an object you do: rating = (rating * number_of_votes + new_rating) / (number_of_votes + 1) number_of_votes += 1 .. save ... Then just sort by rating directly... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Interesting, I''m sorry I missed all the follow-ups on this thread! For the record, what I ended up doing was taking the sum of all the ratings, adding the number of ratings minus one to that number, then dividing that total by the number of ratings. So a single, five-star rating gives a result of 5, as does a recipe rated with a four-star and five-star rating. Two five-star ratings gives 5.5, three five-stars gives you 5.66, and so on. This was a weird solution, but it works fine for my goal of keeping recipes with a single five-star rating from showing up at the top of my list. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---