首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LightFM建议:交互数据出现不一致错误

LightFM建议:交互数据出现不一致错误
EN

Stack Overflow用户
提问于 2018-05-12 23:30:04
回答 1查看 718关注 0票数 1

我有以下LightFM推荐模块的基本代码:

代码语言:javascript
复制
# Interactions
A=[0,1,2,3,4,4] # users
B=[0,0,1,2,2,3] # items
C=[1,1,1,1,1,1] # weights
matrix = sparse.coo_matrix((C,(A,B)),shape=(max(A)+1,max(B)+1))
# Create model
model = LightFM(loss='warp')
# Train model
model.fit(matrix, epochs=30)
# Predict
scores = model.predict(1, np.array([0,1,2,3]))
print(scores)

这将返回以下错误:

代码语言:javascript
复制
> C:\Program
> Files\Python\Python36\lib\site-packages\numpy\core\_methods.py:32:
> RuntimeWarning: invalid value encountered in reduce   return
> umr_sum(a, axis, dtype, out, keepdims) Traceback (most recent call
> last):   File "run.py", line 15, in <module>
>     model.fit(matrix, epochs=100)   File "C:\Program Files\Python\Python36\lib\site-packages\lightfm\lightfm.py", line 476,
> in fit
>     verbose=verbose)   File "C:\Program Files\Python\Python36\lib\site-packages\lightfm\lightfm.py", line 580,
> in fit_partial
>     self._check_finite()   File "C:\Program Files\Python\Python36\lib\site-packages\lightfm\lightfm.py", line 410,
> in _check_finite
>     raise ValueError("Not all estimated parameters are finite," ValueError: Not all estimated parameters are finite, your model may
> have diverged. Try decreasing the learning rate or normalising feature
> values and sample weights

奇怪的是,在交互数据中进行一些更改会使其正常工作,例如:

代码语言:javascript
复制
# Interactions
A=[0,1,2,3,4,4]
B=[0,0,1,2,2,10] # notice the 10 here
C=[1,1,1,1,1,1]

有没有人能帮我一下?

EN

回答 1

Stack Overflow用户

发布于 2018-08-23 23:57:44

代码语言:javascript
复制
#Predict
scores = model.predict(1, np.array([0,1,2,3]))
print(scores)

[-0.17697991 -0.55117112 -0.37800685 -0.57664376]

它对我来说很好,更新lightFM版本?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50307866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档