神級程式設計師帶來的:基於Python和Tensorflow的電影推薦演算法!
阿新 • • 發佈:2019-01-03
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