Skip to content

Commit b72e530

Browse files
committed
readme
1 parent 2b16279 commit b72e530

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
1-
bayesian-classifier
2-
===================
1+
Naive Bayesian Classifier
2+
=========================
3+
This is an implementation of a Naive Bayesian Classifier written in Python. The utility uses statistical methods to classify documents, based on the words that appear within them. A common application for this type of software is in email spam filters.
4+
5+
The utility must first be 'trained' using large numbers of pre-classified documents, during the training phase a database is populated with information about how often certain words appear in each type of document. Once training is complete, unclassified documents can be submitted to the classifier which will return a value between 0 and 1, indicating the probablity that the document belongs to one class of document rather than another.
6+
7+
Training
8+
--------
9+
10+
To train the utility, use the following command:
11+
12+
python bayes.py learn <doctype> <file> <count>
13+
14+
+ The *doctype* argument can be any non-empty value - this is just the name you have chosen for the type of document that you are showing to the classifier
15+
+ The *file* argument indicates the location of the file containing the training data that you wish to use
16+
+ The *count* argument is a numeric value indicating the number of separate documents contained in the training data file
17+
18+
For example:
19+
20+
python bayes.py learn spam all_my_spam.txt 10000
21+
python bayes.py learn ham inbox.txt 10000
22+
23+
Classification
24+
--------------
25+
26+
Once training is complete, classification is performed using this command:
27+
28+
bayes.py classify <file> <doctype> <doctype>
29+
30+
+ The *file* argument indicates the location of the file containing the document to be classified
31+
+ The two *doctype* arguments are the names of the document types against which the input file will be compared
32+
33+
For example:
34+
35+
python bayes.py classify nigerian_finance_email.txt spam ham
36+
> Probability that document is spam rather than ham is 0.98

0 commit comments

Comments
 (0)