本文整理汇总了Python中rbm.RBM.run_visible方法的典型用法代码示例。如果您正苦于以下问题:Python RBM.run_visible方法的具体用法?Python RBM.run_visible怎么用?Python RBM.run_visible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rbm.RBM
的用法示例。
在下文中一共展示了RBM.run_visible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from rbm import RBM [as 别名]
# 或者: from rbm.RBM import run_visible [as 别名]
ratings_wide = ratings_wide.astype(int)
training_data = ratings_wide.as_matrix()
print('starting training')
rbm.train(training_data, max_epochs = 20) # Don't run the training for more than 5000 epochs.
while(True):
userInput = raw_input('enter "run" to predict: ')
if userInput=="run":
user_liked =[]
with open(serverPath+'user_liked.json', 'r') as infile:
user_liked = json.load(infile)
#ipdb.set_trace()
user_liked = [ int(i) for i in re.sub(r"\[|]","",user_liked).split(',')]
user_liked_vec = [int(j) for j in [i in user_liked for i in pd.Series(ratings_wide.columns) ]]
visible_data = np.array([user_liked_vec])
hidden = rbm.run_visible(visible_data)
recom = rbm.run_hidden(hidden)
recom_idx = [idx for idx,i in enumerate(recom[0]) if i==1]
recom_movies = pd.Series(ratings_wide.columns)[recom_idx]
recommendations = recom_movies.tolist()
if(len(recommendations))>=10:
recommendations = recommendations[0:10]
recommendations_title = movies.loc[[i in recommendations for i in movies['movieId']]][['movieId','title']]
#ipdb.set_trace()
with open(serverPath+'recommendations.json', 'w') as outfile:
json.dump(recommendations_title.to_json(), outfile)