Giter Site home page Giter Site logo

crm114-python's Introduction

CRM-114 Python Module

This project is a Python module to interact with The CRM-114 Discriminator, 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 of Elegant Chaos and Born Sleepy, with ongoing improvements and maintenance by Brian Cline.

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.

crm114-python's People

Contributors

briancline avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.