MaartenGr / BERTopic

Leveraging BERT and c-TF-IDF to create easily interpretable topics.
https://maartengr.github.io/BERTopic/
MIT License
5.76k stars 716 forks source link

None Object is returned on .learn_one #2004

Closed Proteusiq closed 1 month ago

Proteusiq commented 1 month ago

removed the assignment as it would self.model to None. self.model.predict_one returns None. Just like dictionary update. So assignment kill the object.

MaartenGr commented 1 month ago

Ah, that should indeed be changed. No comments here, LGTM!

hamedbh commented 2 weeks ago

I'm not sure if the online docs have been re-rendered since this branch was merged, but the definition of the River class in the river section for Online Topic Modelling still has the incorrect assignment syntax for self.model.learn_one(umap_embedding), i.e.:

from river import stream
from river import cluster

class River:
    def __init__(self, model):
        self.model = model

    def partial_fit(self, umap_embeddings):
        for umap_embedding, _ in stream.iter_array(umap_embeddings):
            self.model = self.model.learn_one(umap_embedding)

        labels = []
        for umap_embedding, _ in stream.iter_array(umap_embeddings):
            label = self.model.predict_one(umap_embedding)
            labels.append(label)

        self.labels_ = labels
        return self
MaartenGr commented 2 weeks ago

@hamedbh Ah right, I forgot to update that documentation. I just did and it should now be correct.

hamedbh commented 2 weeks ago

@MaartenGr that's great, thank you!