Skip to content

psantacl/naive-bayes-clj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# bayesian-classifier

A naive bayesian classifier supporting both traditional classification and Paul Graham's variant outlined in "A Plan for Spam"

## Usage

make-classifier accepts N category names as keywords and returns a classifer:
(def *healthy-sick-classifier* (make-classifier :healthy :sick))

If you wish to use agents or atoms for your concurrency mechanism then by all means, do this:
(def *healthy-sick-classifier-atom* (atom (make-classifier :healthy :sick))
(def *healthy-sick-classifier-agent* (agent (make-classifier :healthy :sick))

Next, you'll want to give it some training data. learn! will throw an exception if you attempt to
classify data into a concept/class that is currently not in the classifer.  learn will just roll with this
and create the new concept/class on the fly.

(learn! *healthy-sick-classifier* "fred" :sick)
(swap! learn! *healthy-sick-classifier* "fred" :sick)
(send *healthy-sick-classifier-agent* learn! "fred" :first)

Use one of the support methods to categorize new data. These classifications algo's utilize protocols
to ensure type transparency.  They will work seemless with vanilla classifier maps, atoms or agents:
(p-of-class-given-token *healthy-sick-classifier* "betty")
(p-of-class-given-token-graham *healthy-sick-classifier* "mary")

Persisting trained classifiers is trivial:
(save-classifier *healthy-sick-classifer* "chicken.txt")
(load-classifier "chicken.txt")

## Installation

Typical leiningen project rules apply.

## License

Copyright (C) 2010 Do What Thou Wilt Shall Be The Whole Of The Law.

About

A Naive Bayesian Classifier in Clojure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published