Giter Site home page Giter Site logo

doc_nb_classfier's Introduction

Document Classifier using Naive Bayes Alorithm

Use the data provided by the website to classify 1000 documents into 20 newsgroup categories.

Data : https://www.cs.cmu.edu/afs/cs/project/theo-11/www/naive-bayes.html

Stop words setup required

The code utilizes a nltk library for importing of the stopwords. To setup, please use the below mentioned code in the Python console.

import nltk
nltk.download('stopwords')

Problem Statement

The data set contains 19997 documents which belong to 20 different classes. We need to train our naïve bayes algorithm on 50% of the data set, i.e., 9998 documents(approximately 500 documents from each class) and use the remaining 50% as the testing set and predict the predicted classes (newsgroups) to calculate the accuracy of the naïve bayes algorithm.

Strategy

The frequency of words in the document can be used to predict the class of the document. We calculate the number of words in each class by pre-processing the document and then we calculate the probability of each word in the class. We also calculate prior value for each class. Then using the Bayes theorem, we calculate the predicted class values. We use the above-mentioned formula in our algorithm to calculate the probability of a test document belonging to a class by calculating the probabilities for each class and the maximum value among that is our predicted value.

doc_nb_classfier's People

Contributors

agx01 avatar

Watchers

 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.