神级程序员带来的:基于Python和Tensorflow的电影推荐算法!

userId movieId rating timestamp  
99999 671 6268 2.5 1065579370
100000 671 6269 4.0 1065149201
100001 671 6365 4.0 1070940363
100002 671 6385 2.5 1070979663
100003 671 6565 3.5 1074784724

movieId title genres  
9120 162672 Mohenjo Daro (2016) Adventure|Drama|Romance
9121 163056 Shin Godzilla (2016) Action|Adventure|Fantasy|Sci-Fi
9122 163949 The Beatles: Eight Days a Week - The Touring Y... Documentary
9123 164977 The Gay Desperado (1936) Comedy
9124 164979 Women of '69, Unboxed Documentary

movieId title genres movieRow  
9120 162672 Mohenjo Daro (2016) Adventure|Drama|Romance 9120
9121 163056 Shin Godzilla (2016) Action|Adventure|Fantasy|Sci-Fi 9121
9122 163949 The Beatles: Eight Days a Week - The Touring Y... Documentary 9122
9123 164977 The Gay Desperado (1936) Comedy 9123
9124 164979 Women of '69, Unboxed Documentary 9124

movieRow movieId title  
9120 9120 162672 Mohenjo Daro (2016)
9121 9121 163056 Shin Godzilla (2016)
9122 9122 163949 The Beatles: Eight Days a Week - The Touring Y...
9123 9123 164977 The Gay Desperado (1936)
9124 9124 164979 Women of '69, Unboxed

userId movieRow rating  
0 1 30 2.5
1 7 30 3.0
2 31 30 4.0
3 32 30 4.0
4 36 30 3.0

第三步:构建模型

 
 
loss = 1/2 * tf.reduce_sum(((tf.matmul(X_parameters, Theta_parameters, transpose_b = True) - rating_norm) * record) ** 2) + 1/2 * (tf.reduce_sum(X_parameters ** 2) + tf.reduce_sum(Theta_parameters ** 2))#基于内容的推荐算法模型

函数解释:

reduce_sum() 就是求和,reduce_sum( input_tensor, axis=None, keep_dims=False, name=None, reduction_indices=None)

reduce_sum() 参数解释:

查看训练结果

在终端输入 tensorboard --logir=./

第五步:评估模型

 
 
4037.9002717628305

第六步:构建完整的电影推荐系统

本文章内容来自慕课网,仅供学习,如有侵权,联系删除

欢迎大家关注我的博客:https://home.cnblogs.com/u/sm123456/

欢迎大家加入千人交流学习群:125240963

猜你喜欢

转载自blog.csdn.net/qq_42156420/article/details/80342676