When using pyLDAvis.sklearn.prepare
to visualize an LDA topic model, I encountered the following error message:
>>> pyLDAvis.sklearn.prepare(lda_model, dtm, vectorizer)
...
---> 12 return dtm.sum(axis=1).getA1()
...
AttributeError: 'numpy.ndarray' object has no attribute 'getA1'
Passing dtm
into pyLDAvis.sklearn.prepare
as a pd.DataFrame
raises a similar error:
AttributeError: 'Series' object has no attribute 'getA1'
Why is this error message occurring?