duandian4501 2012-05-24 21:13
浏览 47
已采纳

贝叶斯评级设置

I'm trying to figure how I would start setting up the Bayesian rating system in MYSQL. I am not using a 5 star rating, but something similar. Mine will be a 5 volume bar.

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

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

The 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 should I start setting this up? Should $this_rating be in the same table as the album?


Additional information
  • Tables in MYSQL: Albums, Songs, Genres, Solo, Group
  • Already has foreign keys linkage
  • 写回答

1条回答 默认 最新

  • doz15449 2012-05-24 22:25
    关注

    your initial ideas for a rating scheme are likely to change ( especially for the album ), so you're best off to store transactional information which will let you recompute everything whenever you want.

    create a new table called "Ratings" that fkeys on "Songs" and "Users":

    • id
    • song_id
    • (album_id)
    • user_id
    • rating

    album_id isn't necessary since you have the song_id, but it'll save some time and disk-space is cheap

    add the following fields to the database:

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

    periodically run a script that updates the summary_ fields to whatever you want them to be.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起