本文整理匯總了Python中rbm.RBM.run_hidden方法的典型用法代碼示例。如果您正苦於以下問題:Python RBM.run_hidden方法的具體用法?Python RBM.run_hidden怎麽用?Python RBM.run_hidden使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rbm.RBM
的用法示例。
在下文中一共展示了RBM.run_hidden方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: print
# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import run_hidden [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)