Hey guys, 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: Num_Votes and Vote_Total, and the rating is Num_Votes/Vote_Total. Problem is, it can be easily skewed if their are a low number of votes (1 vote of 5 will boost them to a 5 star rating). Thanks guys!
$total_stars_to_show = 5; $total_voters = 16; #assumed $total_ratings = 47; #assumed $average = ($total_ratings / $total_voters) * $total_stars_to_show; PHP: Now it also depends upton the width of the image you use tod display a star. For example width per star image is 10 pixels, then you will create a <span of $average * 10, which will be in code as: $positive = (int)($average * 10); PHP: and populating the two spans first for positive feedback and remaining the negative, thus: $total_width = 10 * $total_stars_to_show; $negative = $tota_width - $positive; PHP: $positive:$negative ------------------- +++++++:--------- ------------------- CSS Assuming height of image too is 10 pixels. .Cpositive { background-color:blue; background-image:url("positive_star.gif"); height:10px; } .Cnegative { background-color:gray; background-image:url("negative_star.gif"); background-position:top right; height:10px; } HTML: PHP echo "<span class=\"Cpositive\" style=\"width:{$positive}px\"> echo "<span class=\"Cnegative\" style=\"width:{$negative}px\"> PHP: I hope it helps, if this is what you required.
so does it work better. for example. i had a video rated 4 times and it had 4 stars, and a video that hadnt had any ratings and i rated it a 5 star and it became the top rated video.. but it really wasnt due to 1 vote and the other video had 4 votes.. i want to fix that problem... any way?
That's a really good post - I should look into it for improving my own website! A simple alternative (but not as good) is to show the number of ratings along with the average rating, then the user will see which ratings are more reliable.