Coder Social home page Coder Social logo

naivebayes's Introduction

In this lab, I implemented the Naive Bayes algorithm in Python from scratch and I used it to tackle the
“20 Newsgroups “ classification problem. The model is multinomial and uses the “bag of words”
approach. The summaries below show the class priors, overall accuracies, class accuracies, and
confusion matrices for both training and testing data for two different posterior probability estimators:
the maximum likelihood estimator (MLE) and the Bayesian estimator (BE).


The program naiveBayes2.py must be run with python3 (it was made with and tested with Python 3.5.2). Also, the program is multithreaded and will use all cores availible. (It was tested on a laptop with 8 cores and 16 GB memory and it runs for about a minute.)

The following libraries must be installed:
csv
itertools
multiprocessing
math
pprint
pandas
sys

run the following command to install any library: python3 -m pip install library --user

usage:
type into terminal: python3 naiveBayes2.py train_label.csv train_data.csv test_label.csv test_data.csv vocabulary.txt

naivebayes's People

Contributors

ekloberdanz avatar

Watchers

James Cloos avatar

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.