Code Monkey home page Code Monkey logo

bayesian-classifier's Introduction

Naive Bayesian Classifier

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.

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.

Training

To train the utility, use the following command:

python bayes.py learn <doctype> <file> <count>
  • 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
  • The file argument indicates the location of the file containing the training data that you wish to use
  • The count argument is a numeric value indicating the number of separate documents contained in the training data file

For example:

python bayes.py learn spam all_my_spam.txt 10000
python bayes.py learn ham inbox.txt 10000

Classification

Once training is complete, classification is performed using this command:

python bayes.py classify <file> <doctype> <doctype>
  • The file argument indicates the location of the file containing the document to be classified
  • The two doctype arguments are the names of the document types against which the input file will be compared

For example:

python bayes.py classify nigerian_finance_email.txt spam ham
> Probability that document is spam rather than ham is 0.98

bayesian-classifier's People

Contributors

codebox avatar thecapacity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bayesian-classifier's Issues

Use of get_doctype_counts

I am not able to understand why you have created method get_doctype_counts in db.py.
You have called this function in classifier.py but have not used it there also.

Also while training in learn.py do we need to provided all the data in single file?
If yes ,wont it be good if you ask directory as argument where all the input files are kept of the specified label?

Unable to read specified file

when I am trying to classify I got an error like this

Unable to read specified file "surat-izin.jpg.txt", the error message was: object of type 'filter' has no len()

what does it mean?

diffculties in understanding the code

sir actually i am a beginner in python programming.so i am having problem in understanding that how am i going to train my data using the code and classify? can u explain it to me ?

Specify a license

Thanks for writing this! I see on your website that you are releasing this as open source software. I wonder if you could choose a license and add it to the repository?

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.