My question is specific for Gensim and Colab, not other notebook.
I am trying to apply Non-Negative Matrix factorization in Colab with Gensim.
but I can't get the models.nmf
I also read this question without reaching my expected goal.
I followed these steps:
!pip3 install gensim (and I get the attached screenshot)
import gensim
from gensim import models, interfaces, utils
from gensim.models import Nmf
Again I am focused on running the Non-negative Matrix factorization on Google Colab.
Gensim's development repository history shows the gensim/models/nmf.py
file arrived in January 2019, just before the Gensim 3.7.0 release of January 18, 2019.
If you display gensim.__version__
in your Colab notebook, you are likely to find that Google has, by default, only made very-old Gensim 3.6.0 available. That was released September 2018, more than 4 years ago.
If you install a more-recent version of Gensim that actually includes the Nmf
class, you should be able to import Nmf
without error.
Supplying the -U
flag to your install command may be enough to get the most-recent version of Gensim, which will have the most recent functionality, fixes, and optimizations: !pip install gensim -U
If you've already imported an older-version gensim into your notebook, you may need to restart your notebook's Python interpreter so it recognizes the updated package is available and can import it. (I think Colab will remind you to do this when necessary.)