Skip to main content

The bayesian spam classifier from SpamBayes

Project description

This package contains a stripped down version of the SpamBayes classifier, with the following changes:

  • The classifier and tokenizer code has been kept. All other code has been removed.

  • The tokenizer has been stripped down and simplified. In particular all code designed specifically for email parsing has been removed.

  • The ClassifierDb class has been reduced to a simple dict subclass. The custom pickling code has been removed, as have all database backends.

  • The remaining code has been updated and made compatible with Python 3.

  • An orthogonalsparse bigram (OSB) transformation has been added.

  • Unicode handling has been improved.

What’s it good for?

I use sbclassifier to protect websites against contact form spam.

With a training set of a handful each of spam and non-spam messages it is already useful. Once the training data set gets above about 20 messages of each type I am happy to let it filter out the most obvious spam.

Usage

The above script will print out:

0.902
[('*H*', 0.104), ('*S*', 0.908), ('can', 0.155), ('for', 0.845), ('service', 0.845), ('traffic', 0.845), ('and', 0.908)]

sbclassifier assigns 90% probability to this unknown message being spam. It can also produce a sequence of (word, probability) pairs that reveals the tokens that were important in this calculation.

More information

The spambayes source repository contains a wealth of information on how and why the classifier works as it works, as does the SpamBayes wiki.

Project details


Download files

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

Source Distribution

sbclassifier-0.1.1.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

sbclassifier-0.1.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file sbclassifier-0.1.1.tar.gz.

File metadata

  • Download URL: sbclassifier-0.1.1.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.12

File hashes

Hashes for sbclassifier-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f5325eab7e420556c264259f7f5101512c70355c8a49305153ddba412b861cfa
MD5 a4540a944e8417f049c338b67309b54d
BLAKE2b-256 fe4507febace62ef829dde32649d8495a8cd0679e99e2a3a5c745ef61150b9c7

See more details on using hashes here.

File details

Details for the file sbclassifier-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sbclassifier-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.12

File hashes

Hashes for sbclassifier-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e23eff61b57e49c3df5afff432698d87e784223fdc970302488bc257f4236a5b
MD5 f6fb7f1abb9184e41c0c521d753c0e1c
BLAKE2b-256 ea00debdecd5991ccb48ddd0aae2607cda17c3776962b7c034716007269cc9b2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page