Django-slopeone is a project mainly written in Python, based on the BSD-3-Clause license.
Rating predictions based on the Slope One algorithm
Generates rating predictions based on the Slope One algorithm. The rating predictions can be used for recommendations.
You can check out the following links about the Slope One algorithm:
Note: This project is under development and things will most likely change. Don't use it in production systems.
You need Django 1.1.
setup.py install
slopeone
in INSTALLED_APPS
manage.py syncdb
Rating
table. You can use the admin for that.manage.py update_calculations
commandslopeone.core.recommend
and execute it with the user
for which the recommendations should be generated.The recommend
method will return a list of recommendations.
The output looks like this:
[(2, 5.0), (1, 3.0)]
Each element is a pair consisting of the recommended object id and the predicted rating. In this case, the predicted rating for item 2 is 5.0 and for item 1 it's 3.0. The list is sorted descending by rating.
If you cloned the git repo, you can use the testproject
to test this project.
The testproject includes 2 users and 3 rated (animal) fixtures. Here are some
usage instructions:
(0. You need the slopeone
module installed/in your pythonpath.)
manage.py syncdb
in the testproject
dir but don't create
a superuser.manage.py loaddata fixtures/*
.
(username==password for the user fixtures)The following ratings have been added:
arthur | ? | 4
manage.py update_calculations
command, to compute all
required values.To compute the predicted rating for the user arthur
and the animal object
cat
, you can run the manage.py show_recommendations
command with the
user id 2 as an argument:
./manage.py show_recommendations 2
$ [(2, 6.0), (1, 4.0)]
As you see, the predicted rating for arthur/cat would be 6.0. This is because there is only one other user (admin), and he rated cat with 5 and dog with 3. So the global difference between dog and cat rating is +2. Since arthur rated dog with 4, the prediction will apply the difference of the global cat/dog rating to the value of the dog rating. So that 4+2=6.
The rating for the object with the id 1 is not computed since the user has manually rated that object. Rated items are currently not excluded from the return value of the recommend method.