kakao / buffalo

TOROS Buffalo: A fast and scalable production-ready open source project for recommender systems
Apache License 2.0
575 stars 106 forks source link

"TypeError: can't convert complex to float" in train #16

Closed westhyena closed 4 years ago

westhyena commented 5 years ago

I tried training ALS with the code below.

from buffalo.algo.als import ALS
from buffalo.algo.options import ALSOption
from buffalo.data.mm import MatrixMarketOptions

als_option = ALSOption().get_default_option()
data_option = MatrixMarketOptions().get_default_option()
data_option.input.main = file_path

als = ALS(als_option, data_opt=data_option)
als.initialize()
als.train()

It works fine most of the times but sometime it shows following error.

/home/jungwoo/anaconda3/envs/tf-1.14/lib/python3.7/site-packages/buffalo-1.0.10-py3.7-linux-x86_64.egg/buffalo/algo/als.py", line 189, in train
    self.logger.info('Iteration %d: RMSE %.3f Elapsed %.3f secs' % (i + 1, rmse, train_t))
TypeError: can't convert complex to float

I checked types and values of the variables related to rmse.

loss_nume <class 'float'> -333616678.7680697
_loss_nume1 <class 'float'> 0.4414959544501471
_loss_nume2 <class 'float'> -333616679.20956564
loss_deno <class 'float'> 423116401.48691034
_loss_deno1 <class 'float'> 0.0
_loss_deno2 <class 'float'> 423116401.48691034
self.opt.eps <class 'float'> 1e-10
rmse <class 'complex'> (5.4371936760851956e-17+0.8879611133382754j)

rmse becomes complex

ita9naiwa commented 5 years ago

Could you show the data used?

it may happen when the training matrix has negative elements

westhyena commented 5 years ago

@ita9naiwa You were right. There were negative elements in my data.

ummae commented 4 years ago

@westhyena It seems problem about data, I will closed this issue.