naive-bayes-clj
所属分类:聚类算法
开发工具:Clojure
文件大小:5KB
下载次数:0
上传日期:2010-11-28 23:12:44
上 传 者:
sh-1993
说明: Clojure中的朴素贝叶斯分类器
(A Naive Bayesian Classifier in Clojure)
文件列表:
project.clj (294, 2010-11-29)
src (0, 2010-11-29)
src\bayesian_classifier (0, 2010-11-29)
src\bayesian_classifier\core.clj (8850, 2010-11-29)
test (0, 2010-11-29)
test\bayesian_classifier (0, 2010-11-29)
test\bayesian_classifier\test (0, 2010-11-29)
test\bayesian_classifier\test\core.clj (5725, 2010-11-29)
# 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.
近期下载者:
相关文件:
收藏者: