算法采摘翻阅行动项目算法、行动、项目

2023-09-11 04:26:43 作者:用Smile無視一切

我有一个潘多拉般的软件,用户可以在拇指一首歌曲或拇指向下一首歌曲。的软件,称为 Chavah 时,是Silverlight的+ C#,但是这是一个语言和平台中立问题。

I have a Pandora-like piece of software where the user can thumb up a song or thumb down a song. The software, called Chavah, is Silverlight + C#, but this is a language- and platform-neutral question.

我的软件需要选择基于用户的preferences一首歌曲。我需要一个好的算法这一点。

我希望我的软件选择要播放的歌曲给出的以下要求:

I want my software to choose a song to play given the following requirements:

翻阅了歌曲应该受到青睐, 并定期播放。

Thumbed up songs should be favored, and played regularly.

无星级 歌曲(既不翻阅上不去也下不来) 还是应该发挥;毕竟, 用户可能只有2总 翻阅起来的歌曲。

Unrated songs (neither thumbed up nor down) should still be played; after all, the user may only have 2 total thumbed up songs.

翻阅下来的歌曲应该很少出场。

Thumbed down songs should be played rarely.

不管是什么算法,歌曲不应该经常重复。

Whatever the algorithm, songs should not repeat often.

由于这些设计决策,有没有一些好的算法吗?

Given these design decisions, is there some good algorithm here?

我有一些code,抓住所有的歌曲,喜欢的歌曲,和不喜欢的歌曲:

I have some code that grabs all songs, liked songs, and disliked songs:

var allSongs = ...
var likedSongs = allSongs.Where(s => s.LikedByUser(...));
var dislikedSongs = allSongs.Where(s => s.DislikedByUser(...));

任何简单的想法,挑选一首好歌用户?

Any simple ideas for picking a good song for the user?

推荐答案

您可以体重歌曲;说的每首歌都有1.0在开始得分,0.5如果翻阅下来,1.5如果翻阅了起来。然后,你选择从集中的所有得分的随机元素,其概率由它的,嗯,不过重量称重。快速和肮脏的方法,我会认为这里将是总结了所有的权重。选择一个随机数比总和。遍历所有歌曲,直到CurrentWeight + SongWeight> RandomNumber(否则CurrentWeight + = SongWeight)

You can weight songs; say every song has a score of 1.0 in the beginning, 0.5 if thumbed down and 1.5 if thumbed up. Then you pick a random element from the set of all scores, with its probability however weighed by its, um, weight. The fast and dirty approach I'd think of here would be to sum over all weights. Pick a random number smaller than that sum. Loop over all songs until CurrentWeight+SongWeight > RandomNumber (else CurrentWeight+=SongWeight)

当然,你可以通过引入协同过滤使这个任意更复杂的:)

Of course you can make this arbitrarily more complex by introducing collaborative filtering :)

想象一下,五首歌曲。前两个翻阅了起来,下一次翻阅下来,两个中性。

Imagine five songs. First two thumbed up, next one thumbed down, two neutral.

{1:1.5; 2:1.5,3:0.5,4:1,5:1}

{1: 1.5, 2: 1.5, 3:0.5, 4: 1, 5:1}

此的总和是5.5。现在,我们选择一个随机数LT; 5.5看:这是2.43789

The sum of this is 5.5. Now we pick a random number < 5.5 and see: It's 2.43789

现在,让我们找到这个随机数所属的歌曲。

Now let's find the song this random number belongs to.

开始用CurrentWeight = 0一首歌的体重= 1.5。 CurrentWeight + 1.5&LT; 2.43789 - >我们继续,但通过这首歌的重量增加CurrentWeight。

Start with CurrentWeight = 0. First song's weight = 1.5. CurrentWeight+1.5 < 2.43789 -> we continue, but increase CurrentWeight by this song's weight.

所以CurrentWeight = 1.5现在。下一首歌曲的体重:再次1.5。但现在,CurrentWeight + 1.5 = = 3> 2.43789。这意味着我们选择了第二首歌曲!

So CurrentWeight = 1.5 now. Next song's weight: again 1.5. But now, CurrentWeight+1.5 == 3 > 2.43789. This means we chose the second song!

你要做的就是在这里基本上挑线路上的随机点,但增加在该行的领土,将选择一首歌曲如果歌曲翻阅了起来。

What you do here is to basically pick a random spot on a line, but increase the "territory" on that line that would choose a song if the song is thumbed up.

这是否产生了许多重复与否基本上取决于你如何大力增加/减少的歌曲权重。

Whether this creates many repetitions or not basically depends on how strongly you increase/decrease the songs' weights.