DeepClassifier is aimed at building general text classification model library.It's easy and user-friendly to build any text classification task.
Project description
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!🤩
- TextCNN: Convolutional Neural Networks for Sentence Classification ,2014 EMNLP
- RCNN: Recurrent Convolutional Neural Networks for Text Classification,2015,IJCAI
- DPCNN: Deep Pyramid Convolutional Neural Networks for Text Categorization ,2017,ACL
- HAN: Hierarchical Attention Networks for Document Classification, 2016,ACL
- BERT: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding,2018, ACL
- BertTextCNN: BERT+TextCNN
- BertRCNN: BERT+RCNN
- BertDPCNN: BERT+DPCNN
- 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 BertTexCNN 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 2843656167@qq.com.🥳
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepclassifier-0.0.6.tar.gz.
File metadata
- Download URL: deepclassifier-0.0.6.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e061f57af859ea058cc1e54a3b97a90ad51675d90f9bcf7056936846efbb9293
|
|
| MD5 |
001b5a427a53f534baf91fa6d299b4b5
|
|
| BLAKE2b-256 |
1827ce627c1ef4be30b49756e803ce62d6f015a595bebee21b7a5394efee7f4a
|
File details
Details for the file deepclassifier-0.0.6-py3-none-any.whl.
File metadata
- Download URL: deepclassifier-0.0.6-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9e611b08ec1bb226dab833e02b6133e9e55f5d7ee221ce6c4f41eac31f07eda
|
|
| MD5 |
095bdb2a32b522e22a9674d59da63a4a
|
|
| BLAKE2b-256 |
d96113774ad825ddd6e1d5af546b8cbf2c64cf5d5ccef1ada2b9c3ebf0e021a2
|