All Projects → codewithzichao → DeepClassifier

codewithzichao / DeepClassifier

Licence: Apache-2.0 License
DeepClassifier is aimed at building general text classification model library.It's easy and user-friendly to build any text classification task.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to DeepClassifier

MetaLifelongLanguage
Repository containing code for the paper "Meta-Learning with Sparse Experience Replay for Lifelong Language Learning".
Stars: ✭ 21 (-16%)
Mutual labels:  text-classification
NewsMTSC
Target-dependent sentiment classification in news articles reporting on political events. Includes a high-quality data set of over 11k sentences and a state-of-the-art classification model.
Stars: ✭ 54 (+116%)
Mutual labels:  text-classification
text-classification-small-datasets
Building a text classifier with extremely small datasets
Stars: ✭ 34 (+36%)
Mutual labels:  text-classification
TorchGA
Train PyTorch Models using the Genetic Algorithm with PyGAD
Stars: ✭ 47 (+88%)
Mutual labels:  torch
textgo
Text preprocessing, representation, similarity calculation, text search and classification. Let's go and play with text!
Stars: ✭ 33 (+32%)
Mutual labels:  text-classification
resnet.torch
an updated version of fb.resnet.torch with many changes.
Stars: ✭ 35 (+40%)
Mutual labels:  torch
Product-Categorization-NLP
Multi-Class Text Classification for products based on their description with Machine Learning algorithms and Neural Networks (MLP, CNN, Distilbert).
Stars: ✭ 30 (+20%)
Mutual labels:  text-classification
Kaggle-project-list
Summary of my projects on kaggle
Stars: ✭ 20 (-20%)
Mutual labels:  text-classification
Caver
Caver: a toolkit for multilabel text classification.
Stars: ✭ 38 (+52%)
Mutual labels:  text-classification
Python-for-Text-Classification
Python for Text Classification with Machine Learning in Python 3.6.
Stars: ✭ 32 (+28%)
Mutual labels:  text-classification
neuralBlack
A Multi-Class Brain Tumor Classifier using Convolutional Neural Network with 99% Accuracy achieved by applying the method of Transfer Learning using Python and Pytorch Deep Learning Framework
Stars: ✭ 36 (+44%)
Mutual labels:  torch
torch-lrcn
An implementation of the LRCN in Torch
Stars: ✭ 85 (+240%)
Mutual labels:  torch
HiGitClass
HiGitClass: Keyword-Driven Hierarchical Classification of GitHub Repositories (ICDM'19)
Stars: ✭ 58 (+132%)
Mutual labels:  text-classification
Naive-Resume-Matching
Text Similarity Applied to resume, to compare Resumes with Job Descriptions and create a score to rank them. Similar to an ATS.
Stars: ✭ 27 (+8%)
Mutual labels:  text-classification
Neural-Zoom
Infinite Zoom For Style Transfer
Stars: ✭ 34 (+36%)
Mutual labels:  torch
classification
Vietnamese Text Classification
Stars: ✭ 39 (+56%)
Mutual labels:  text-classification
TorchBlocks
A PyTorch-based toolkit for natural language processing
Stars: ✭ 85 (+240%)
Mutual labels:  text-classification
Text and Audio classification with Bert
Text Classification in Turkish Texts with Bert
Stars: ✭ 34 (+36%)
Mutual labels:  text-classification
monkeylearn-java
Official Java client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Java apps.
Stars: ✭ 23 (-8%)
Mutual labels:  text-classification
NSP-BERT
The code for our paper "NSP-BERT: A Prompt-based Zero-Shot Learner Through an Original Pre-training Task —— Next Sentence Prediction"
Stars: ✭ 166 (+564%)
Mutual labels:  text-classification

DeepClassifier

DeepClassifier is a python package based on pytorch, which is easy-use and general for text classification task. You can install DeepClassifier by pip install -U deepclassifier。 If you want to know more information about DeepClassifier, please see the documentation. So let's start!🤩

If you think DeepClassifier is good, please star and fork it to give me motivation to continue maintenance!🤩 And it's my pleasure that if Deepclassifier is helpful to you!🥰

Installation

Just like other Python packages, DeepClassifier also can be installed through pip.The command of installation is pip install -U deepclassifier.

Models

Here is a list of models that have been integrated into DeepClassifier. In the future, we will integrate more models into DeepClassifier. Welcome to join us!🤩

  1. TextCNN: Convolutional Neural Networks for Sentence Classification ,2014 EMNLP
  2. RCNN: Recurrent Convolutional Neural Networks for Text Classification,2015,IJCAI
  3. DPCNN: Deep Pyramid Convolutional Neural Networks for Text Categorization ,2017,ACL
  4. HAN: Hierarchical Attention Networks for Document Classification, 2016,ACL
  5. BERT: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding,2018, ACL
  6. BertTextCNN: BERT+TextCNN
  7. BertRCNN: BERT+RCNN
  8. BertDPCNN: BERT+DPCNN
  9. BertHAN: BERT+HAN ...

Quick start

I wiil show you that how to use DeepClassifier below.🥰 Click [here] to display the complete code.

you can define model like that(take BertTextCNN model as example):👇

from deepclassifier.models import BertTextCNN

# parameters of model
embedding_dim = 768  # if you use bert, the default is 768.
dropout_rate = 0.2
num_class = 2
bert_path = "/Users/codewithzichao/Desktop/bert-base-uncased/"

my_model = BertTextCNN(embedding_dim=embedding_dim,
                       dropout_rate=dropout_rate,
                       num_class=num_class,
                       bert_path=bert_path)

optimizer = optim.Adam(my_model.parameters())
loss_fn = nn.CrossEntropyLoss()

After defining model, you can train/test/predict model like that:👇

from deepclassifier.trainers import Trainer

model_name = "berttextcnn"
save_path = "best.ckpt"
writer = SummaryWriter("logfie/1")
max_norm = 0.25
eval_step_interval = 20

my_trainer =Trainer(model_name=model_name,model=my_model,
                    train_loader=train_loader,dev_loader=dev_loader,
                    test_loader=test_loader, optimizer=optimizer, 
                    loss_fn=loss_fn,save_path=save_path, epochs=1, 
                    writer=writer, max_norm=max_norm,
                    eval_step_interval=eval_step_interval)

# training
my_trainer.train()
# print the best F1 value on dev set
print(my_trainer.best_f1)

# testing
p, r, f1 = my_trainer.test()
print(p, r, f1)

# predict
pred_data = DataLoader(pred_data, batch_size=1)
pred_label = my_trainer.predict(pred_data)
print(pred_label)

Contact me

If you want any questions about DeepClassifier, welcome to submit issue or pull requests! And welcome to communicate with me through [email protected].🥳

Citation

@misc{zichao2020deepclassifier,
author = {Zichao Li},
title = {DeepClassifier: use-friendly and flexiable package of NLP based text classification models},
year = {2020},
publisher = {GitHub},
journal = {GitHub Repository},
howpublished = {\url{https://github.com/codewithzichao/DeepClassifier}},
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].