Skip to main content

Django Bayesian inference based comment moderation app.

Project description

Django Moderator

Django Bayesian inference based comment moderation app.

django-moderator integrates Django’s comments framework with SpamBayes to automatically classify comments into three categories, ham, spam or unknown, based on previous training (see Paul Graham’s A Plan for Spam for some background).

Comments classified as unknown have to be manually classified as either spam or ham via admin, thereby training the system to automatically classify similarly worded comments in future.

Comments classified as spam will have their is_removed field set to True and as such it will no longer be visible in comment listings.

Comments classified as ham will remain unchanged and as such will be visible in comment listings.

django-moderator also implements a user friendly admin interface for efficiently moderating comments.


  1. Install or add django-moderator to your Python path.

  2. Add moderator to your INSTALLED_APPS setting.

  3. Add a MODERATOR setting to your project’s file. This setting specifies what classifier storage backend to use (see below) and also classification thresholds:

        'CLASSIFIER': '',
        'HAM_CUTOFF': 0.3,
        'SPAM_CUTOFF': 0.7,

    Specifically a HAM_CUTOFF value of 0.3 as in this example specifies that any comment scoring less than 0.3 during Bayesian inference will be classified as ham. A SPAM_CUTOFF value of 0.7 as in this example specifies that any comment scoring more than 0.7 during Bayesian inference will be classified as spam. Anything between 0.3 and 0.7 will be classified as unsure, awaiting manual user classification. HAM_CUTOFF and SPAM_CUTOFF can be ommited in which case the default cuttofs are 0.3 and 0.7 respectively.

Classifier Storage Backends

django-moderator includes two SpamBayes storage backends, and respectively.

Note is recommended for production environments as it should be much more performant than

To use as your classifier storage backend specify it in your MODERATOR setting, i.e.:

    'CLASSIFIER': '',
        'host': 'localhost',
        'port': 6379,
        'db': 0,
        'password': None,
    'HAM_CUTOFF': 0.3,
    'SPAM_CUTOFF': 0.7,

You can aslo create your own backends, in which case take note that the content of CLASSIFIER_CONFIG will be passed as keyword agruments to your backend’s __init__ method.


Once correctly configured you’ll use the classifycomments management command to automatically classify comments as either ham, spam or unsure based on previous training, i.e.:

$ ./ classifycomments

Unsure comments can be manually classified as either ham or spam via the Classified comments page in admin.


Praekelt Foundation

  • Shaun Sephton


0.0.1 (2012-05-23)

  1. Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-moderator, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_moderator-0.0.1-py2.7.egg (24.1 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size django-moderator-0.0.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page