powerscorinne / GLRM

MIT License
97 stars 49 forks source link

Trouble running mixed.py #2

Open jc-healy opened 8 years ago

jc-healy commented 8 years ago

Hi there,

After reading your paper I'm very excited to give your GLRM code a try but am having trouble getting it running. I hit some dependency trouble with cvxpy and got around it by using "conda install -c https://conda.anaconda.org/omnia cvxpy" which might be handy to add to your readme.

When I try and run your example in mixed.py I initially get an "ImportError: cannot import name unroll_missing" I noticed that it was commented out of your util.py so dropped it from the script.

My error is now unfortunately in glrm.fit() here is the code snippet and error. Any idea how I might get this running?

A = [data_real, data_ord, data_bool]
loss = [QuadraticLoss, OrdinalLoss, HingeLoss]
regX, regY = QuadraticReg(0.01), QuadraticReg(0.01)
converge = Convergence(TOL = 1e-2, max_iters = 1000) # optional (default TOL = 1e-3)
glrm_mix = GLRM(A, loss, regX, regY, k, converge = converge)
glrm_mix.fit()

AttributeError                            Traceback (most recent call last)
<ipython-input-14-99b26bc6fae3> in <module>()
----> 1 glrm_mix.fit()

/home/towermint/anaconda3/envs/py2/lib/python2.7/site-packages/GLRM-0.0.1-py2.7.egg/glrm/glrm.pyc in fit(self, max_iters, eps, use_indirect, warm_start)
     64             self.converge.obj.append(objX)
     65 
---> 66         self._finalize_XY(Xv, Yv)
     67         return self.X, self.Y
     68 

/home/towermint/anaconda3/envs/py2/lib/python2.7/site-packages/GLRM-0.0.1-py2.7.egg/glrm/glrm.pyc in _finalize_XY(self, Xv, Yv)
    162     def _finalize_XY(self, Xv, Yv):
    163         """ Multiply by std, offset by mean """
--> 164         m, k = Xv.shape.size
    165         self.X = asarray(hstack((Xv.value, ones((m,1)))))
    166         self.Y = [asarray(yj.value)*tile(mask[0,:],(k+1,1)) \

AttributeError: 'Variable' object has no attribute 'shape'

Cheers, John

tonyabracadabra commented 8 years ago

Just change m, k = Xv.shape.size to m, k = Xv.size would fix.

kfolw commented 6 years ago

I am also having trouble running the mixed.py and the readme examples. I updated all dependencies including cvxpy and numpy, and tried the above fix, but still get the following error when I run model.fit():

/Users/anaconda/lib/python2.7/site-packages/cvxpy/expressions/leaf.pyc in _validate_value(self, val)
     84                 raise ValueError(
     85                     "Invalid dimensions (%s, %s) for %s value." %
---> 86                     (size[0], size[1], self.__class__.__name__)
     87                 )
     88             # All signs are valid if sign is unknown.

ValueError: Invalid dimensions (0, 1) for CallbackParam value.
abhiML commented 6 years ago

@kfolw did u find a solution? I am getting the same error with cvxpy 0.4.

kfolw commented 6 years ago

No I ended up using the R/H2O.ai implementation, and that worked great.

abhiML commented 6 years ago

Were you successful in imputing missing categorical data using the h20.ai implementation?

abhiML commented 6 years ago

Reconstruction is horrible in the case of categorical variables. I checked across 2 datasets from UC Irvine repo.

kfolw commented 6 years ago

@abhiML I did not need to impute categorical data for my dataset, maybe try different loss functions to see if that improves imputation?

abhiML commented 6 years ago

I tried all of the loss functions given in h2o.ai. The imputation algo doesnt work on categorical data. Unless there's something I'm missing completely. It cant even reconstruct the original dataset from the low rank decomposition in case of categorical data. On numeric data it works fine.