iskandr/fancyimpute

Keras/Tensorflow Version Issue

redraven984 opened this issue · 9 comments

Hello, I was using fancyimpute with no problems until a couple weeks ago when I updated by conda environment. Now it seems that fancyimpute is no longer compatible with the new version of keras. I have the following import error " cannot import regularizers from keras".

I started a new conda environment, with python 3.6, keras 2.4.3, and tensorflow 2.2.0. Now when I run matrix factorization I have the following error: AttributeError: module 'keras.optimizers' has no attribute 'nadam'

Can you please help me to resolve these dependency issues?

I guess Keras made a lot of changes recently, and we haven't really kept up. The right move is to probably just update the code and the requirements but I'm extremely busy at the moment. I'll put this on my todo list.

Actually maybe the fix is easy. See #129.

Hopefully it's fixed. Try to install the new version from pip in a new environment.

Let me check! Thanks for hopping on this so quick!

Sorry which Keras version should I put in my new environment?

The keras issue is to be fixed!

There seems to be an additional issue with scipy. Here is my sample code and the output:

iterSVDImp = fancyimpute.IterativeSVD(verbose = False)
testMat = np.random.randn(10,10)
testMat[0][0] = np.nan

iterSVDImp.fit_transform(testMat)

Output:

ValueError Traceback (most recent call last)
in
3 testMat[0][0] = np.nan
4
----> 5 iterSVDImp.fit_transform(testMat)

~/anaconda3/envs/py36FancyImpute/lib/python3.6/site-packages/fancyimpute/solver.py in fit_transform(self, X, y)
184 type(X_filled)))
185
--> 186 X_result = self.solve(X_filled, missing_mask)
187 if not isinstance(X_result, np.ndarray):
188 raise TypeError(

~/anaconda3/envs/py36FancyImpute/lib/python3.6/site-packages/fancyimpute/iterative_svd.py in solve(self, X, missing_mask)
72 curr_rank = self.rank
73 tsvd = TruncatedSVD(curr_rank, algorithm=self.svd_algorithm)
---> 74 X_reduced = tsvd.fit_transform(X_filled)
75 X_reconstructed = tsvd.inverse_transform(X_reduced)
76 X_reconstructed = self.clip(X_reconstructed)

~/anaconda3/envs/py36FancyImpute/lib/python3.6/site-packages/sklearn/decomposition/_truncated_svd.py in fit_transform(self, X, y)
167
168 if self.algorithm == "arpack":
--> 169 U, Sigma, VT = svds(X, k=self.n_components, tol=self.tol)
170 # svds doesn't abide by scipy.linalg.svd/randomized_svd
171 # conventions, so reverse its outputs.

~/anaconda3/envs/py36FancyImpute/lib/python3.6/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py in svds(A, k, ncv, tol, which, v0, maxiter, return_singular_vectors, solver)
1815
1816 if k <= 0 or k >= min(n, m):
-> 1817 raise ValueError("k must be between 1 and min(A.shape), k=%d" % k)
1818
1819 if isinstance(A, LinearOperator):

ValueError: k must be between 1 and min(A.shape), k=10

That looks like you need to specify a valid rank. Try fancyimpute.IterativeSVD(rank=3) instead. Your test matrix is larger than the default rank.

Thanks for your help! It is most appreciated!