Repository navigation
Releases: maximtrp/tmplot
Release list
tmplot: v0.5.0
Breaking Changes
- HDP dead topics dropped.
get_phi()/get_theta()return only live topics for tomotopyHDPModel. Fewer topics than before, and columns/index now carry the model's own ids (e.g.[6, 8, 24, 25]) instead of0..k-1. Warns when dropping. Other model types unaffected. - bitermplus >= 1.0 required.
p(z|d)is no longer stored onBTM, soget_theta()needs the documents:get_theta(model, corpus=get_vectorized_docs(docs, vocab)).BTMClassifierneeds no corpus. entropy()raises for a single topic. Rényi entropy is undefined at T=1 (q = 1/T = 1zeroes theF/(q-1)denominator). Previously returned an arbitrary fallback. Matches bitermplus 1.0.get_closest_topics()rejects out-of-range or negativerefinstead of silently clamping; empty model list errors.get_stable_topics()validates array shapes andref.
New Features
entropy()accepts either orientation. W×T (asget_phireturns) or T×W, inferred from which axis sums to 1. Newtopics_axisargument states it explicitly; a value contradicting the data now errors instead of returning a wrong number.BTMClassifiersupport, end to end —get_phi,get_theta,prepare_coords,report.prepare_coords()accepts precomputedphi/theta.
Bug Fixes
entropy()silently returned wrong numbers for a transposed matrix —1.1625vs the correct0.7272on one 40×30 phi, with no error. It selects the topic count, so this could change published conclusions.- Dead HDP topics corrupted everything downstream — entropy
0.0995where the true value was1.5524. lle/ltsacrashed on collapsed topic distances ("output dimension must be less than or equal to input dimension").- An HDP model with no live topics returned an empty phi; now raises.
- Jaccard
top_words=0raisedZeroDivisionError; negative values silently returned wrong distances. report()failed whendocswas a NumPy array.- Selected topic was not highlighted when using a custom
topic_col. - Duplicate word labels pushed genuine terms out of
calc_terms_probs_ratio(). get_top_docs()gave an opaqueIndexErrorfor an out-of-range topic._is_btm_classifier()returnedNoneinstead ofFalse.get_closest_topics()validatedmethodonly after loading the reference model.
Performance
Distances are computed on whole matrices instead of looping over topic pairs; Jaccard sorts once per topic rather than once per pair. Results unchanged — identical for Jaccard, below 1e-13 elsewhere.
| 5000 words × 50 topics | Before | After |
|---|---|---|
get_topics_dist (sklb) |
0.21 s | 0.005 s |
get_topics_dist (jac) |
1.00 s | 0.031 s |
get_closest_topics (sklb) |
1.86 s | 0.021 s |
get_closest_topics (jac) |
6.13 s | 0.096 s |
report() now reads phi and theta once each instead of up to five times.
Compatibility
- scikit-learn 1.4 through 1.9+. MDS takes
dissimilaritybefore 1.9 andmetricfrom 1.9; both branches are tested, and CI runs the declared floor (1.4.2). entropy()matchesbitermplus.entropynumerically at default settings. Note the flag is named in opposite directions: tmplotmax_probs=False== bitermplusmax_probs=True.- CI matrix gained Python 3.11; package classifiers gained 3.13.
Internal
- Tests 102 → 257; line coverage 93% → 99%.
tmplot: v0.4.0
- Fixed Jaccard topic matching and KL/Jeffrey divergence calculations.
- Corrected topic-distance embeddings and two-topic model handling.
- Improved comparisons across models with different vocabularies or topic counts.
- Fixed prevalence-weighted term probabilities and relevance rankings.
- Vectorized saliency calculations and optimized top-document selection.
- Strengthened input validation and optional model adapter handling.
- Improved interactive report reliability and caching.
- Added extensive regression coverage: 102 tests passing with 92% coverage.
- Added Python 3.9–3.14 CI and built-package validation.
tmplot: v0.3.0
- Fixed Jensen-Shannon and symmetric Kullback-Leibler divergence calculation (was using incorrect formulas)
- Fixed variable name bug in report interface
- Fixed sklearn MDS FutureWarning
- Added comprehensive input validation for probability matrices
- Cached phi matrix calculations to reduce redundant calls
- Added error handling for edge cases (division by zero, log(0))
- Added bounds checking and empty data validation
- Improved numerical stability with named constants
- Enhanced error messages for better debugging
tmplot: v0.2.0
This release fixed issues in marginal distribution and saliency calculations.
tmplot: v0.1.3
This release fixes a number of bugs in report method and slightly improves type hinting (thanks to @Nfsaavedra and @franciee2): #11, #13
tmplot: v0.1.2
tmplot: v0.1.1
This release fixes the lower bound error in TSNE perplexity setting (#6, #9, thanks to @caicai555, @Yif18). It also includes minor code and package improvements.
tmplot: v0.1.0
This release fixes an error in get_phi method, adds some basic tests (to be added more in future), and updates packaging configs.
tmplot: v0.0.10
This release introduces improvements to entropy calculation method.
tmplot: v0.0.9
This release fixes a bug in topic scatter plot (#6) and optimizes t-SNE parameters for calculating topics 2D coordinates for scatter plot. It also includes minor cosmetic changes and fixes.