newbtophp Posted August 25, 2010 Share Posted August 25, 2010 Hey!, Just looking for some advice on developing a voting/rating algorithm. What is the most effective way to develop this? Right now, I am using minimalistic/very simple algorithm, I have two columns: number_of_votes and total_vote, and the score = number_of_votes/total_vote Problem is, it can be easily skewed if their are a low number of votes (1 vote of 5 will boost the score to 5). PS: They can vote from 1-5 (the max the score can be is 5) Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/211732-voting-system-flaw/ Share on other sites More sharing options...
newbtophp Posted August 30, 2010 Author Share Posted August 30, 2010 Someone suggest using bayesian algorithm, but I'm not sure how to implant that using my current db structure (without the score going over 5) Any help or any better way you can think of (to improve upon my current method)? Quote Link to comment https://forums.phpfreaks.com/topic/211732-voting-system-flaw/#findComment-1105113 Share on other sites More sharing options...
Alex Posted August 30, 2010 Share Posted August 30, 2010 I don't see anything wrong with your current method. That is generally how all star voting systems work. People vote 1-5 and you display the average of those votes. So what if the first vote is 5 and that boosts it to 5 automatically? That's why you also display the number of votes so people don't get the wrong idea. Quote Link to comment https://forums.phpfreaks.com/topic/211732-voting-system-flaw/#findComment-1105124 Share on other sites More sharing options...
newbtophp Posted August 30, 2010 Author Share Posted August 30, 2010 I don't see anything wrong with your current method. That is generally how all star voting systems work. People vote 1-5 and you display the average of those votes. So what if the first vote is 5 and that boosts it to 5 automatically? That's why you also display the number of votes so people don't get the wrong idea. Well I know but say if theirs 1 vote of 5, the score will = 5 (however thats 1 voters opinion which can effect the importance or quality of the content), and if for example I display a 'Top X' based upon their score, they can jump to the list. I googled around and found the following: http://www.thebroth.com/blog/118/bayesian-rating But seems abit too mathematical for me to integrate, so was hoping someone could help me. EDIT: added a better example Quote Link to comment https://forums.phpfreaks.com/topic/211732-voting-system-flaw/#findComment-1105134 Share on other sites More sharing options...
Alex Posted August 30, 2010 Share Posted August 30, 2010 Well, then what you're looking for isn't another way to handle star ratings (In fact, any other way would be pretty misleading). Instead, you're looking for a way to rank different entries overall. One such way, as you mentioned in the Bayesian rating system, of which the average star rating is one factor. Here's an example MySQL implementation of the weighted Bayesian rating system using your current setup: SELECT * FROM table ORDER BY (number_of_votes / (number_of_votes + 0) * (total_vote / number_of_votes) + (0 / (number_of_votes + 0)) * (SELECT AVG(total_vote / number_of_votes) FROM table) DESC LIMIT 10 That should work, but with your current setup I can't think of any way to do it without a subquery. If your database structure was nicer it would be easier. Note that if you want to require a minimum number of votes for it to be selected in the query (and displayed on the top X rated) you'll need to change the 0s in that query to whatever requirement you want. Quote Link to comment https://forums.phpfreaks.com/topic/211732-voting-system-flaw/#findComment-1105144 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.