A better default scoring script for Amarok 2
Karthik Periagaram
karthikp at gatech.edu
Sun Dec 14 04:33:46 CET 2008
Hi all,
Me again. Here are the three changes that need to be made to the codebase to
improve the default scoring algorithm.
1) File: src/Amarok.h line 90
Change function definition of computeScore() to the following:
inline double computeScore( double oldScore, int playCount, double
playedFraction, int rating )
{
double newScore;
if( rating == 0 )
rating = 5;
if( playCount == 0 )
oldScore = 0;
newScore = ( ( 5 * rating + 0.5 * oldScore ) + ( 100 - ( 5 * rating + 0.5 *
oldScore ) ) * ( playCount / ( playCount + 1 ) ) ) * ( 0.9 + 0.1 *
playedFraction );
return newScore;
}
Then,
2) File: collection/sqlcolllection/SqlMeta.cpp line 755
Change function call
setScore( Amarok::computeScore( score(), playCount(), playedFraction, rating()
) );
3) File: collection/nepomukcollection/NepomukTrack.cpp line 316
Change function call
setScore( Amarok::computeScore( score(), playCount(), playedFraction, rating()
) );
With these changes, the score algorithm change is complete. The new score will
agree with your rating more and will approach 100 as the song playcount tends
to infinity. Thus, it is a better algorithm to calculate how much the song is
liked by the user.
To test the change, it helps to set all scores to zero. A bit of mysql-fu
should do it (though I don't know how to play with those things). I just nuked
the contents of ~/.kde4/share/apps/amarok, but that might not be an ideal
solution to most people. :)
Again, if you have questions, do ask me and I'll explain why this is awesome
and how when plotted, this function looks really cool. :) Thanks all, for
helping me put this together.
(markey: I figured #include <cmath> might not be needed after all- I replaced
exp( -x ) with 1/(x+1) and it works equally fine!)
Karthik
More information about the Amarok-devel
mailing list