tmplot
tmplot is a Python package for analysis and visualization of 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 topic distances and a number of algorithms for calculating scatter coordinates of topics. It can be used to select closest and stable topics across multiple models.
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(optional)
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
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 tmplot-0.1.2.tar.gz.
File metadata
- Download URL: tmplot-0.1.2.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
971d836a03d41f0b22070907e532195e42787ccd76a8a94730d40b3327cd3f90
|
|
| MD5 |
945d64153a9db82cc3495e827487a01b
|
|
| BLAKE2b-256 |
1ce9b685fa6af32c108820cd01de3ae314835bee390c5db1f36eeb7a2766b5df
|
File details
Details for the file tmplot-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tmplot-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7f0546f2daf610f2a8e99297f4c5bd7ab546409531b2a3a3b9cb43de1f15745
|
|
| MD5 |
c03d11ce8e1d31460ea3ec6374cf2786
|
|
| BLAKE2b-256 |
c2d32d90317f18e246fc134bac379c6b2fa86b44af9e3085c92b37c3cff6fd1a
|