1. 程式人生 > >神級程式設計師帶來的:基於Python和Tensorflow的電影推薦演算法!

神級程式設計師帶來的:基於Python和Tensorflow的電影推薦演算法!

userIdmovieIdratingtimestamp
9999967162682.51065579370
10000067162694.01065149201
10000167163654.01070940363
10000267163852.51070979663
10000367165653.51074784724

movieIdtitlegenres
9120162672Mohenjo Daro (2016)Adventure|Drama|Romance
9121163056Shin Godzilla (2016)Action|Adventure|Fantasy|Sci-Fi
9122163949The Beatles: Eight Days a Week - The Touring Y...Documentary
9123164977The Gay Desperado (1936)Comedy
9124164979Women of '69, UnboxedDocumentary

movieIdtitlegenresmovieRow
9120162672Mohenjo Daro (2016)Adventure|Drama|Romance9120
9121163056Shin Godzilla (2016)Action|Adventure|Fantasy|Sci-Fi9121
9122163949The Beatles: Eight Days a Week - The Touring Y...Documentary9122
9123164977The Gay Desperado (1936)Comedy9123
9124164979Women of '69, UnboxedDocumentary9124

movieRowmovieIdtitle
91209120162672Mohenjo Daro (2016)
91219121163056Shin Godzilla (2016)
91229122163949The Beatles: Eight Days a Week - The Touring Y...
91239123164977The Gay Desperado (1936)
91249124164979Women of '69, Unboxed

userIdmovieRowrating
01302.5
17303.0
231304.0
332304.0
436303.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