Giter Site home page Giter Site logo

sandy4321 / word-bags-vs-word-sequences-for-text-classification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashokc/word-bags-vs-word-sequences-for-text-classification

0.0 0.0 0.0 325 KB

Evaluating sequence respecting approaches like LSTM against traditional bag-of-words approaches for text

Python 98.78% Shell 1.22%

word-bags-vs-word-sequences-for-text-classification's Introduction

Word Bags vs Word Sequences for Text Classification

This is the source code to go along with the blog article

Word Bags vs Word Sequences for Text Classification

The blog illustrates that sequence respecting approaches have an edge over bag-of-words implementations when the said sequence is material to classification. Long Short Term Memory (LSTM) neural nets with words sequences are evaluated against Naive Bayes with tf-idf vectors on a synthetic text corpus for classification effectiveness.

Bags Vs Strings

Dependencies

numpy
scikit-learn
keras
tensorflow
matplotlib

Usage

mkdir results

LSTM

A simple LSTM model is implemented via Keras/Tensorflow

LSTM Model

Run it with:

#!/bin/bash
PYTHONHASHSEED=0 ; pipenv run python lstm.py

To get results like:

LSTM Results

Naive Bayes

Naive Bayes is implemented via SciKit

#!/bin/bash
PYTHONHASHSEED=0 ; pipenv run python nb.py

Plot results

		pipenv run python plots.py
		pipenv run python plotConfusionMatrix.py

A comparison of confusion matrices obtained with LSTM and Naive Bayes:

Confusion Matrices

word-bags-vs-word-sequences-for-text-classification's People

Contributors

ashokc 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.