Skip to content

Commit

Permalink
Merge pull request #87 from AnFreTh/main
Browse files Browse the repository at this point in the history
Release 0.1.6
  • Loading branch information
AnFreTh authored Aug 16, 2024
2 parents 1db1f14 + 42076f1 commit 986a221
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ STREAM offers a variety of neural as well as non-neural topic models and we are
<td><a href="https://www.jmlr.org/papers/volume3/blei03a/blei03a.pdf?ref=http://githubhelp.com">LDA</a></td>
<td>Latent Dirichlet Allocation</td>
</tr>
<tr>
<td><a href="https://www.nature.com/articles/44565">NMF</a></td>
<td>Non-negative Matrix Factorization</td>
</tr>
<tr>
<td><a href="https://arxiv.org/abs/2004.14914">WordCluTM</a></td>
<td>Tired of topic models?</td>
Expand Down
14 changes: 9 additions & 5 deletions docs/api/models/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ Models
========


.. autoclass:: stream_topic.models.BERTopicTM
:members:

.. autoclass:: stream_topic.models.CBC
:members:

.. autoclass:: stream_topic.models.CEDC
:members:
Expand Down Expand Up @@ -40,3 +35,12 @@ Models

.. autoclass:: stream_topic.models.CTMNeg
:members:

.. autoclass:: stream_topic.models.NMFTM
:members:

.. autoclass:: stream_topic.models.BERTopicTM
:members:

.. autoclass:: stream_topic.models.CBC
:members:
4 changes: 4 additions & 0 deletions docs/landingpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ STREAM offers a variety of neural as well as non-neural topic models and we are
<td><a href="https://www.jmlr.org/papers/volume3/blei03a/blei03a.pdf?ref=http://githubhelp.com">LDA</a></td>
<td>Latent Dirichlet Allocation</td>
</tr>
<tr>
<td><a href="https://www.nature.com/articles/44565">NMF</a></td>
<td>Non-negative Matrix Factorization</td>
</tr>
<tr>
<td><a href="https://arxiv.org/abs/2004.14914">WordCluTM</a></td>
<td>Tired of topic models?</td>
Expand Down
2 changes: 1 addition & 1 deletion stream_topic/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ = "0.1.5"
__version__ = "0.1.6"
2 changes: 2 additions & 0 deletions stream_topic/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .neurallda import NeuralLDA
from .ctmneg import CTMNeg
from .tntm import TNTM
from .nmf import NMFTM

__all__ = [
"BERTopicTM",
Expand All @@ -28,4 +29,5 @@
"NeuralLDA",
"CTMNeg",
"TNTM",
"NMFTM",
]
9 changes: 6 additions & 3 deletions stream_topic/models/abstract_helper_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ def optimize_hyperparameters(
assert criterion in [
"aic",
"bic",
"recon",
"custom",
], "Criterion must be either 'aic', 'bic', or 'custom'."
], "Criterion must be either 'aic', 'bic', 'recon' or 'custom'."
if criterion == "custom":
assert (
custom_metric is not None
Expand All @@ -363,12 +364,14 @@ def objective(trial):
self.fit(dataset)

# Calculate the score based on the criterion
if criterion in ["aic", "bic"]:
if criterion in ["aic", "bic", "recon"]:

if criterion == "aic":
score = self.calculate_aic(n_topics=self.hparams["n_topics"])
else:
elif criterion == "bic":
score = self.calculate_bic(n_topics=self.hparams["n_topics"])
elif criterion == "recon":
score = self.reconstruction_loss()
else:
# Compute the custom metric score
topics = self.get_topics()
Expand Down
Loading

0 comments on commit 986a221

Please sign in to comment.