Skip to content

YujunZhong/text-classification-models

Repository files navigation

Text Classification Models

This repository contains code for text multi-classification tasks. The following four models are implemented:

  • Naive Bayes classifier using Bag of words feature
  • Linear SVM
  • Neural network
  • Long short-term memory network (LSTM)

Run command

Naive Bayes and SVM

Before training naive bayes and SVM models, we need to generate new dataset files:

cd tools

python data_process.py

Train the Naive bayes model:

python nb_svm_train.py nb

Train the SVM model:

python nb_svm_train.py svm

Test a Naive bayes or SVM model:

python nb_svm_inference.py svm

SVM with word2Vec

Pay attention to the data path. Follow the steps in the 'svm_with_word2vec.ipynb'.

Neural nets

Train a simple neural network:

python nn_train.py

Test a simple neural network:

python nn_inference.py

LSTM and Explainability of LSTM

Pay attention to the data path. Follow the steps in the 'LSTM.ipynb'.

About

Training and inference code for text classification models

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published