Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于基于图模型代码问题 #5

Open
wushupei1997 opened this issue May 30, 2020 · 0 comments
Open

关于基于图模型代码问题 #5

wushupei1997 opened this issue May 30, 2020 · 0 comments

Comments

@wushupei1997
Copy link

@Magic-Bubble ,你好,我是一名推荐系统新手,发现您对推荐系统这本书所复现的代码,非常感谢您的开源!我在复现第二章基于图的模型的代码中,遇到了些许问题,查找很多资料,没有解决不知您是否愿意给出建议?

获取接口函数

def GetRecommendation(user):
    seen_items = set(train[user])
    # 解矩阵方程 r = (1-a)r0 + a(M.T)r
    r0 = [0] * len(data)
    r0[users[user]] = 1
    r0 = csc_matrix(r0)
    r = (1 - alpha) * linalg.inv(eye(len(data)) - alpha * M.T) * r0
    r = r.T.toarray()[0][len(users):]
    idx = np.argsort(-r)[:N]
    recs = [(id2item[ii], r[ii]) for ii in idx]
    return recs

return GetRecommendation

r = (1 - alpha) * linalg.inv(eye(len(data)) - alpha * M.T) * r0,这句代码,在运行时会出现“SparseEfficiencyWarning: splu requires CSC matrix format
warn('splu requires CSC matrix format', SparseEfficiencyWarning)”这样的提示,我不太清楚这里出现了什么问题,希望您百忙之中给出些许建议,感谢!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant