Textvec is a text vectorization tool, with the aim to implement all the "classic" text vectorization NLP methods in Python. The main idea of this project is to show alternatives for an excellent TFIDF method which is highly overused for supervised tasks. All interfaces are similar to scikit-learn so you should be able to test the performance of this supervised methods just with a few changes.
Textvec is compatible with: Python 2.7-3.7.
WHY: Comparison with TFIDF
As you can read in the different articles1,2 almost on every dataset supervised methods outperform unsupervised.
But most text classification examples on the internet ignores that fact.
|IMDB_bin||RT_bin||Airlines Sentiment_bin||Airlines Sentiment_multiclass||20news_multiclass|
Here is a comparison for binary classification on imdb sentiment data set. Labels sorted by accuracy score and the heatmap shows the correlation between different approaches. As you can see some methods are good for to ensemble models or perform features selection.
For more dataset benchmarks (rotten tomatoes, airline sentiment) see Binary classification quality comparison
pip install textvec
git clone https://github.com/zveryansky/textvec cd textvec pip install .
The usage is similar to scikit-learn:
from sklearn.feature_extraction.text import CountVectorizer from textvec.vectorizers import TfBinIcfVectorizer cvec = CountVectorizer().fit(train_data.text) tficf_vec = TfBinIcfVectorizer(sublinear_tf=True) tficf_vec.fit(cvec.transform(text), y)
Currently impletented methods:
Most of the vectorization techniques you can find in articles1,2. If you see any method with wrong name or reference pls commit!
- [ ] Add TFBNS
- [ ] Remove dependence of sklearn
- [ ] Tests
- [ ] Docs
- [ ] GridSearch for benchmark
Subscribe to Python Awesome
Get the latest posts delivered right to your inbox