Skip to main content

tmplot

Codacy coverage Codacy grade GitHub Workflow Status Documentation Status Downloads PyPI Issues

tmplot is a comprehensive Python package for topic modeling analysis and visualization. Built for data scientists and researchers, it provides powerful interactive reports and advanced analytics that extend beyond traditional LDAvis/pyLDAvis capabilities.

AnalyzeVisualizeCompare multiple topic models with ease

Plots

Key Features

Interactive Visualization

  • Topic scatter plots with customizable coordinates and sizing
  • Term probability charts with relevance weighting
  • Document analysis showing top documents per topic
  • Interactive reports with real-time parameter adjustment

Advanced Analytics

  • Topic stability analysis across multiple model runs
  • Model comparison with sophisticated distance metrics
  • Saliency calculations for term importance
  • Entropy metrics for model optimization

Model Support

  • tomotopy: LDAModel, LLDAModel, CTModel, DMRModel, HDPModel, PTModel, SLDAModel, GDMRModel
  • gensim: LdaModel, LdaMulticore
  • bitermplus: BTM

Distance Metrics

  • Kullback-Leibler (symmetric & non-symmetric)
  • Jensen-Shannon divergence
  • Jeffrey's divergence
  • Hellinger & Bhattacharyya distances
  • Total variation distance
  • Jaccard index

Dimensionality Reduction

t-SNE, SpectralEmbedding, MDS, LocallyLinearEmbedding, Isomap

Donate

If you find this package useful, please consider donating any amount of money. This will help me spend more time on supporting open-source software.

Buy Me A Coffee

Quick Start

Installation

# From PyPI (recommended)
pip install tmplot

# Development version
pip install git+https://github.com/maximtrp/tmplot.git

Basic Usage

import tmplot as tmp

# Load your topic model and documents
model = your_fitted_model  # tomotopy, gensim, or bitermplus
docs = your_documents

# Create interactive report
tmp.report(model, docs=docs)

# Or create individual visualizations
coords = tmp.prepare_coords(model)
tmp.plot_scatter_topics(coords, size_col='size')

Advanced Examples

Get Stable Topics

import tmplot as tmp

# Find stable topics across multiple models
models = [model1, model2, model3, model4]
closest_topics, distances = tmp.get_closest_topics(models)
stable_topics, stable_distances = tmp.get_stable_topics(closest_topics, distances)

Analyze Model

# Calculate entropy for model selection
entropy_score = tmp.entropy(phi_matrix)

# Analyze topic stability
saliency = tmp.get_salient_terms(phi, theta)

Visualize

# Create topic distance matrix with different metrics
topic_dists = tmp.get_topics_dist(phi, method='jsd')

# Generate coordinates with custom algorithm
coords = tmp.get_topics_scatter(topic_dists, theta, method='tsne')
tmp.plot_scatter_topics(coords, topic=3)  # Highlight topic 3

Documentation & Examples

Requirements

Core dependencies: numpy, scipy, scikit-learn, pandas, altair, ipywidgets

Optional models: tomotopy, gensim, bitermplus

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.4.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tmplot-0.4.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file tmplot-0.4.0.tar.gz.

File metadata

  • Download URL: tmplot-0.4.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tmplot-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d5eabd5ae2dcf41b30ad3ba3c4b6d45435ec2dd660ff6c082430c663cc17a6d8
MD5 c5597e71254bb8ce170b842b04ab6f03
BLAKE2b-256 b3a6c45eb66639594795d135f2e7c59b4492fec494cbc4ddb113b29262591ce1

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmplot-0.4.0.tar.gz:

Publisher: python-publish.yml on maximtrp/tmplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmplot-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: tmplot-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tmplot-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbb32e4617c8b52b0f2f1f2e1b23f87e7158f1dce3ea48cd27c5016af81f6103
MD5 e8f765fdc9ddc81f4fff51ccc4eaf6d0
BLAKE2b-256 267119034cd3160a6b7aa9108e36fc5fc2264cc55297e6ef6ae63e1b26b0ae0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmplot-0.4.0-py3-none-any.whl:

Publisher: python-publish.yml on maximtrp/tmplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.10

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page