按受欢迎程度对歌曲列表进行排序
今年的学生会,我是“歌曲”委员会的成员,我们挑选歌曲。不幸的是,舞会上的孩子们总是讨厌一些愚蠢的歌曲选择。我想今年我可以让它变得不同。上周四,我创建了一个简单的 PHP 应用程序,以便孩子们可以将歌曲提交到数据库中,并提供歌曲名称、艺术家和流派(从下拉列表中)。我还实现了类似于 Reddit 的投票功能。单击“点赞”按钮,您已为该歌曲点赞,点赞数也随之增加。与否决票相同。
Anywho,在数据库中,我有三个我认为可以用来评价这些歌曲的信息:赞成票、反对票和时间戳。有一段时间,排名只是通过将“投票”数较高的歌曲排在顶部来创建的。也就是说,赞成票越多,反对票就越少(赞成票 - 反对票)将位于列表的顶部。这在一段时间内起到了作用,但到周日为止,列表中大约有 75 首歌曲,而且最先提交的歌曲仅仅位于列表的顶部。
周日,我将排名算法更改为(upvotes - downvotes)/(CurrentTimestamp - CreationTimestamp),即在较短的时间内得票数越高,歌曲在列表中的排名就越高。这有效,更好,但仍然不是我想要的。
现在发生的情况是,当一首歌曲被创建并投票到 1 票时,它最终会出现在列表的顶部。投票数为负数的歌曲不会经常被观看,因为孩子们通常不会滚动到底部。
我想我可以对数据进行排序,使较低的歌曲出现在顶部,这样人们就被迫看到较低的歌曲。老实说,我以前从未研究过“流行度”算法,所以,你有什么想法?
网站位于 http://www.songs.tapappysoftware.com - 我不知道是否应该放置无论是否在此处,都可能会在舞会上产生一些不需要的歌曲:0
For student council this year, I'm on the "songs" committee, we pick the songs. Unfortunately, the kids at the dances always end up hating some of the stupid song choices. I thought I could make it different this year. Last thursday, I created a simple PHP application so kids could submit songs into the database, supplying a song name, artist, and genre (from a drop-down). I also implemented a voting feature similar to Reddit's. Click an upvote button, you've upvoted the song, incremented the upvote count. Same with downvotes.
Anywho, in the database, I have three tidbits of information I thought I could use to rate these songs, upvotes, downvotes, and a timestamp. For a while, the rank was created by simply having the songs with the higher "vote" count at the top. That is, the more upvotes, less downvotes (upvotes - downvotes) would be at the top of the list. That worked, for a while, but there were about 75 songs on the list by Sunday, and the songs that were submitted first were simply at the top of the list.
Sunday, I changed the rank algorithm to (upvotes - downvotes) / (CurrentTimestamp - CreationTimestamp), that is, the higher the vote count in the lesser amount of time, the higher the song would be on the list. This works, better, but still not how i'd like it.
What happens now, is that the instant a song is created and upvoted to a vote count of 1, it ends up at the top of the list somewhere. Songs who have vote counts in the negatives aren't viewed often because kids don't usually scroll to the bottom.
I guess I could sort the data so the lower songs appear at the top, so people are forced to see the lower songs. Honestly, I've never had to work on a "popularity" algorithm before, so, what are your thoughts?
Website's at http://www.songs.taphappysoftware.com - I don't know if I should put this here or not, might cause some unwanted songs at the dance :0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个非常好的问题。这里已经提出了一些类似的问题。
这篇文章可能是一个很好的起点。显然,赞成票减去反对票是一个糟糕的方法。更好的方法是使用复杂的数学为每个分数分配分数并按分数排序。
以下是文章中的 Ruby 评分函数:
作为可用性的事情,我会按分数对数据进行排序,但我不会向用户显示分数。我只会显示赞成票和反对票的数量。
That's a very good question. There are a few similar questions that have been asked here.
This article is probably a good place to start. Apparently upvotes minus downvotes is a bad way to do it. The better way is to use complicated maths to assign a score to each and sort by that.
Here is a scoring function in Ruby from the article:
As a usability thing, I would sort the data by the score, but I would not show the score to the user. I would only show the number of upvotes and downvotes.
按发布时间或投票数(负面+正面)对歌曲进行排序怎么样?如果您的目标是给予每首歌同等的关注,这听起来就足够了。
How about sorting songs by posting time or number of votes (negative + positive)? If your goal is to give every song equal attention, this sounds good enough.