dlab-berkeley / Python-Text-Analysis-Legacy-2023

D-Lab's 12 hour introduction to text analysis with Python. Learn how to perform bag-of-words, sentiment analysis, topic modeling, word embeddings, and more, using scikit-learn, NLTK, Gensim, and spaCy in Python.
Creative Commons Attribution 4.0 International
22 stars 9 forks source link

Alpha Hyperparameter is Deprecated #29

Open rbarreto opened 1 year ago

rbarreto commented 1 year ago

I still get a warning when I run the code but some students got an actual error.

This is the code that returns the error:

nmf = NMF( n_components=n_components, random_state=random_state, alpha=0.1, l1_ratio=0.5, init='nndsvda', max_iter=500).fit(tfidf)

This is the error students get:

TypeError: NMF.init() got an unexpected keyword argument 'alpha'

This is the warning I get:

/Users/renatabarreto/opt/anaconda3/lib/python3.7/site-packages/sklearn/decomposition/_nmf.py:1425: FutureWarning: alpha was deprecated in version 1.0 and will be removed in 1.2. Use alpha_W and alpha_H instead FutureWarning,

Marcus-M1999 commented 1 year ago

Additionally, when changing the alpha_W and alpha_H in the given example everything is driven to 0. this is for all values for both alphas greater than 0. Many students asked about this, but I wasn't able to find a satisfactory reason why this is happening.