File selection algorithm

I have a program similar to Pandora where a user can jot down a song or finger down a song. The software, called Chavah , is Silverlight + C #, but this is a language and platform issue.

My software should select a song based on user preferences. I need a good algorithm for this.

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

  • Scattered songs must be approved, and played regularly.

  • Without a song rating (neither up nor down) you still need to play; after all, a user can have only 2 crowded songs.

  • Large songs should rarely play.

  • Regardless of the algorithm, songs should not be repeated frequently.

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

I have a code that captures all songs, favorite songs and dislikes songs:

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

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

+1
source share
4 answers

You can weigh songs; let's say each song has a rating of 1.0 at the beginning, 0.5 if dropped and 1.5 if you click. Then you select a random element from the set of all points, with its probability, but weighted by its weight. A quick and dirty approach that I would think of would be to summarize all the weights. Choose a random number less than this amount. Move all songs until CurrentWeight + SongWeight> RandomNumber (aka CurrentWeight + = SongWeight)

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

Imagine five songs. The first two fingers are up, the next one is a draft down, two are neutral.

{1: 1,5, 2: 1,5, 3: 0,5, 4: 1, 5: 1}

The amount of 5.5. Now we select a random number <5.5 and see: 2.43789

Now find the song to which this random number belongs.

Start with CurrentWeight = 0. First song weight = 1.5. CurrentWeight + 1.5 <2.43789 → we continue, but increase CurrentWeight by this weight of the song.

So CurrentWeight = 1.5. Next song weight: 1.5 again. But now, CurrentWeight + 1.5 == 3> 2.43789. This means that we have chosen the second song!

What you are doing here is basically choosing a random spot on the line, but increase the “territory” on that line, which would select the song if the song was dropped.

This creates a lot of repetition or does not depend mainly on how much you increase / decrease the weight of the songs.

+2
source

I guess Pandora uses a tag system to categorize its songs. This way you determine the user's musical taste profile by sampling the highest frequency of thumbed up tags. Unfortunately, for you, they use a huge database with music labels to offer their users, which is probably more complicated than the algorithm for choosing them.

+1
source

You can also create a rating system for a group / artist and genre, and based on each thumb you can add 1 (or any other value you decide) to both the group and the genre. Then, when it is time to solve the next song, you can weigh the decision based on the user's declared interest in the group / singer and / or genre. And the reverse for the songs is "thumbed down".

+1
source

Maybe something like this:

1) Create three streams (or playlists) of randomly ordered songs, such as a piece of code, but make them mutually exclusive: Liked, Not Liked, Not Rated. Based on the size of these groups, each of them will have a duration until repetition.

2) Create a function that combines threads into one thread, subject to certain rules. The main rule would be the desired combination of flows, say 60% liked it, 38% didn’t rate it, 2% didn’t like it or something else. You will only have to deviate from the desired mix when the length of the Liked stream is too short to follow the “minimum time between song repeats” rule.

3) You probably also want to recount all threads periodically. The hard part here may be to avoid repetition caused by recalculation. Perhaps your random sorting in (1) may also take into account some kind of weight or displacement attached to recently played songs.

+1
source

Source: https://habr.com/ru/post/1387574/


All Articles