Bayesian rating configured

I am trying to understand how I will begin to create a Bayesian rating system in MYSQL. I do not use a 5 star rating, but something like that. The mine will have 5 bars.

This is for my album page. Instead of having users rate the album, they will rate songs that will be averaged to become album ratings.

  • $songsum
  • $songavg
  • $numofrated
  • $totalsongs
  • $albumrating
  • $songsum / $numofrated = $songavg
  • $songavg * ($numofrated / $totalsongs) = $albumrating

Another page (artist page) will also be rated.

$avg_num_votes  = 18;  // Average number of votes in all products
$avg_rating     = 3.7; // Average rating for all products
$this_num_votes = 6;   // Number of votes for this product
$this_rating    = 4;   // Rating for this product

$bayesian_rating =
    ( ($avg_num_votes * $avg_rating) + ($this_num_votes * this_rating) )
  / ($avg_num_votes + $this_num_votes);

How do I start the setup? Should it $this_ratingbe in the same table as the album?


Additional Information
  • Tables in MYSQL: albums, songs, genres, solo, group
  • You already have a relationship with foreign keys
+3
source share
1 answer

, , ( ), , , .

"", fkeys "" "":

  • ID
  • song_id
  • (album_id)
  • user_id

album_id , song_id, ,

:

  • song.summary_votes
  • song.summary_average
  • album.summary_votes
  • album.summary_average

script, summary_ , .

+1

All Articles