Skip to main content

This project is a Python module to interact with [The CRM-114 Discriminator][2], which handles learning and classification of text streams. While written and used primarily in spam classification, CRM-114 handles text streams of logs, data, etc. just as well with recorded accuracy rates exceeding 99.9%. A wide variety of methods can be used with CRM-114, namely regular expressions, approximate regular expressions, Hidden Markov Model, Orthogonal Sparse Bigrams (OSB), winnow, general correlation, K-Nearest-Neighbor, and bit entropy.

Originally crafted by [Sam Deane][3] of [Elegant Chaos][4] and [Born Sleepy][5], with ongoing improvements and maintenance by [Brian Cline][6].

This module provides a very simplified interface to CRM-114. It does not attempt to expose all of CRM-114’s power; instead it tries to hide almost all of the gory details.

Requirements

Python 2.7 is strongly recommended.

Naturally, the crm binary itself is required, and should be in your path. Follow the instructions here for your operating system to install CRM-114.

### Debian, Ubuntu, et al.

apt-get install crm114

### CentOS, Fedora, Red Hat, et al.

## Install and enable the EPEL repository package rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm yum install –enable-repo=epel crm114

### Everyone else

## If you do not yet have libtre and its headers: curl -O http://crm114.sourceforge.net/tarballs/tre-0.7.5.tar.gz tar -zxf tre-.tar.gz cd tre- ./configure –enable-static make sudo make install cd ..

curl -O http://crm114.sourceforge.net/tarballs/crm114-20100106-BlameMichelson.src.tar.gz tar -zxf crm114-.tar.gz cd crm114.src make sudo make install cd ..

Installation

This is really all you need:

sudo pip install crm114

Usage

To use the module, create an instance of the Classifier class, giving it the path to a directory where the data files will be stored, and a list of all possible category strings–or labels–under which text will be classified.

c = Classifier(‘/path/to/my/data’, [‘good’, ‘bad’])

To teach the classifier object about some text, call the learn method passing in a category (one of the categories that you previously provided), and the text.

c.learn(‘good’, ‘some good text’) c.learn(‘bad’, ‘some bad text’)

To find out what the classifier thinks about a body of text, call the classify method, passing in the text. The result of this method is a pair: the first item is a category best matching the text, and the second item is the confidence/probability of that match.

label, confidence = c.classify(‘some text’)

For a rather contrived but possibly helpful detailed example, see tests/basic.py.

License

Released under the MIT License. See LICENSE file for details.

Original code licensed under GPLv2, re-licensed 29 October 2013 by Sam Deane under the MIT license for further curation, maintenance, and packaging.

[1]: http://en.wikipedia.org/wiki/CRM_114_(fictional_device) [2]: http://crm114.sourceforge.net/ [3]: https://github.com/samdeane [4]: http://www.elegantchaos.com/ [5]: http://bornsleepy.com/ [6]: https://github.com/briancline

Download files

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

Source Distribution

crm114-2.0.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file crm114-2.0.0.tar.gz.

File metadata

  • Download URL: crm114-2.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crm114-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b368ec2c9617325640da9fee7082d396bb4a647f9c5abc73899ffb0dff7029cd
MD5 4d61fd99335e213282dc02e5b04de704
BLAKE2b-256 f24e71544cfb8be6ccc325e1a57104af9b8b07e37c38ece6bc61e7874c6cc317

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.2

1 file

2.0.1

1 file

This release

2.0.0 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page