tmplot
tmplot is a Python package for visualizing topic modeling results. It provides the interactive report interface that borrows much from LDAvis/pyLDAvis and builds upon it offering a number of metrics for calculating topics distances and a number of algorithms for calculating scatter coordinates of topics.
Features
-
Supported models:
- tomotopy:
LDAModel,LLDAModel,CTModel,DMRModel,HDPModel,PTModel,SLDAModel,GDMRModel - gensim:
LdaModel,LdaMulticore - bitermplus:
BTM
- tomotopy:
-
Supported distance metrics:
- Kullback-Leibler (symmetric and non-symmetric) divergence
- Jenson-Shannon divergence
- Jeffrey's divergence
- Hellinger distance
- Bhattacharyya distance
- Total variation distance
- Jaccard inversed index
-
Supported algorithms for calculating topics scatter coordinates:
- t-SNE
- SpectralEmbedding
- MDS
- LocallyLinearEmbedding
- Isomap
Installation
The package can be installed from PyPi:
pip install tmplot
Or directly from this repository:
pip install git+https://github.com/maximtrp/tmplot.git
Dependencies
numpyscipyscikit-learnpandasaltairipywidgetstomotopy,gensim, andbitermplus
Quick example
# Importing packages
import tmplot as tmp
import pickle as pkl
import pandas as pd
# Reading a model from a file
with open('data/model.pkl', 'rb') as file:
model = pkl.load(file)
# Reading documents from a file
docs = pd.read_csv('data/docs.txt.gz', header=None).values.ravel()
# Plotting topics as a scatter plot
topics_coords = tmp.prepare_coords(model)
tmp.plot_scatter_topics(topics_coords, size_col='size', label_col='label')
# Plotting terms probabilities
terms_probs = tmp.calc_terms_probs_ratio(phi, topic=0, lambda_=1)
tmp.plot_terms(terms_probs)
# Running report interface
tmp.report(model, docs=docs, width=250)
You can find more examples in the tutorial.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tmplot-0.0.4.tar.gz
(14.0 kB
view details)
File details
Details for the file tmplot-0.0.4.tar.gz.
File metadata
- Download URL: tmplot-0.0.4.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6f49c3dc5cbb01ceb57fd80c7d02fb51d1c229652a05227cc8c143b287b6a7f
|
|
| MD5 |
830e3854c6fae17900665ca8108a4365
|
|
| BLAKE2b-256 |
0e89b6aa990f2e15c3665b25ce75522db27ace40c60366c79d2596195f997cc5
|