Giter Site home page Giter Site logo

naivebayesian's Introduction

Naive Bayesian

In this question, i implemented the Naive Bayes document classifier and apply it to the classic 20 newsgroups [dataset] (http://qwone.com/~jason/20Newsgroups/) In this dataset, each document is a posting that was made to one of 20 different usenet newsgroups.

The goal was to write a program which can predict which newsgroup a given document was posted to.

  1. vocabulary.txt is a list of the words that may appear in documents. The line number is word’s id in other files. That is, the first word (’archive’) has wordId 1, the second (’name’) has wordId 2, etc.

  2. newsgrouplabels.txt is a list of newsgroups from which a docment may have come. Again, the line number corresponds to the label’s id, which is used in the .label files. The first line (’alt.atheism’) has id 1, etc.

  3. train.label Each line corresponds to the label for one document from the training set. Again, the document’s id (docId) is the line number.

  4. test.label The same as train.label, except that the labels are for the test documents.

  5. train.data Specifies the counts for each of the words used in each of the documents. Each line is of the form “docId wordId count”, where count specifies the number of times the word with id wordId in the training document with id docId. All word/document pairs that do not appear in the file have count 0.

  6. test.data Same as train.data, except that it specified counts for test documents.

##how to run:

python nb.py vocabulary.txt train.label train.data test.label test.data

- Khabbab Saleem

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.