Closed MaggieMeow closed 9 months ago
Hello Maggie, thanks for the kind words, and reporting the issue, I will get to work on this and try to get it fixed right away. :D
In the meantime you could try using scikit-learn's implementation of NMF, as I know for a fact that that one works just fine.
It would look something akin to this:
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
from sklearn.pipeline import make_pipeline
texts = [" ".join(text) for text in df["cleanedText"]]
# You can also use MiniBatchNMF with partial_fit() if you run out of memory
topic_pipeline = make_pipeline(TfidfVectorizer(), NMF(10))
topic_pipeline.fit(texts)
topicwizard.visualize(texts, pipeline=topic_pipeline)
If you do not want to refit the model, you can also turn a Gensim Nmf model into an sklearn pipeline like this:
from topicwizard.compatibility.gensim import DictionaryVectorizer
from sklearn.decomposition import NMF
from sklearn.pipeline import make_pipeline
sknmf = NMF(10)
sknmf.components_ = nmf.get_topics()
vectorizer = DictionaryVectorizer(dictionary)
topic_pipeline = make_pipeline(vectorizer, sknmf)
...
Thank you very much for your suggestions!
Anytime. The fix is on the main branch now, but it comes bundled with a bunch of other changes that I have made to accomodate for contextually sensitive topic models, that are coming with the turftopic package.
The next release of topicwizard will ship with the fix.
Hi, there. First, I'd like to say that your package has been very helpful for the visualisation in my topic modelling project. Thank you!
While topic wizard works great with Gensim's lda model for me, running it on gensim's nmf model produced the error "AttributeError: 'Nmf' object has no attribute 'inference'" from topicwizard.visualize().
Here's the full error message:
Here's my code for reproducing the error:
Your help will be much appreciated!