91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

本資源是有關(guān)電視節(jié)目的推薦的,數(shù)據(jù)樣本雖然少了一些,但是代碼完整,希望有用

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
“““
Created?on?Thu?Nov??1?09:33:14?2018

@author:?AZ
“““
import?math
import?pandas?as?pd
import?numpy?as?np
import?os
os.chdir(‘E:/廣電大數(shù)據(jù)營銷推薦項目案例/數(shù)據(jù)清洗/電視節(jié)目信息數(shù)據(jù)預(yù)處理‘)

#?創(chuàng)建節(jié)目畫像
#?參數(shù)說明:
#?items_profiles?=?{item1:{‘label1‘:1?‘label2‘:?0?‘label3‘:?0?...}?item2:{...}...}
def?createItemsProfiles(data_array?labels_names?items_names):
????items_profiles?=?{}
????for?i?in?range(len(items_names)):
????????items_profiles[items_names[i]]?=?{}
????????for?j?in?range(len(labels_names)):
????????????items_profiles[items_names[i]][labels_names[j]]?=?data_array[i][j]
????return?items_profiles

#?創(chuàng)建用戶畫像
#?參數(shù)說明:
#?data_array:?所有用戶對于其所看過的節(jié)目的評分矩陣?data_array?=?[[2?0?0?1.1?...]?[0?0?1.1?...]?...]
#?users_profiles?=?{user1:{‘label1‘:1.1?‘label2‘:?0.5?‘label3‘:?0.0?...}?user2:{...}...}
def?createUsersProfiles(data_array?users_names?items_names?labels_names?items_profiles):
????users_profiles?=?{}
????#?計算每個用戶對所看過的所有節(jié)目的平均隱性評分
????#?users_average_scores_list?=?[1.2?2.2?4.3...]
????users_average_scores_list?=?[]

????#?統(tǒng)計每個用戶所看過的節(jié)目(不加入隱性評分信息)
????#?items_users_saw?=?{user1:[item1?item3?item5]?user2:[...]...}
????items_users_saw?=?{}
????#?統(tǒng)計每個用戶所看過的節(jié)目及評分
????#?items_users_saw_scores?=?{user1:[[item1?1.1]?[item2?4.1]]?user2:...}
????items_users_saw_scores?=?{}
????
????for?i?in?range(len(users_names)):

????????items_users_saw_scores[users_names[i]]?=?[]
????????items_users_saw[users_names[i]]?=?[]
????????count?=?0
????????sum?=?0.0
????????for?j?in?range(len(items_names)):

????????????#?用戶對該節(jié)目隱性評分為正,表示真正看過該節(jié)目
????????????if?data_array[i][j]?>?0:
????????????????items_users_saw[users_names[i]].append(items_names[j])
????????????????items_users_saw_scores[users_names[i]].append([items_names[j]?data_array[i][j]])
????????????????count?+=?1
????????????????sum?+=?data_array[i][j]

????????if?count?==?0:
????????????users_average_scores_list.append(0)
????????else:
????????????users_average_scores_list.append(sum?/?count)

????for?i?in?range(len(users_names)):

????????users_profiles[users_names[i]]?=?{}

????????for?j?in?range(len(labels_names)):
????????????count?=?0
????????????score?=?0.0

????????????for?item?in?items_users_saw_scores[users_names[i]]:

????????????????#?參數(shù):
????????????????#?用戶user1對于類型label1的隱性評分:?user1_score_to_label1
????????????????#?用戶user1對于其看過的含有類型label1的節(jié)目item?i?的評分:?score_to_item?i
????????????????#?用戶user1對其所看過的所有節(jié)目的平均評分:?user1_average_score
????????????????#?用戶user1看過的節(jié)目總數(shù):?items_count

????????????????#?公式:?user1_score_to_label1?=?Sigma(score_to_item?i?-?user1_average_score)/items_count

????????????????#?該節(jié)目含有特定標簽labels_names[j]
????????????????if?items_profiles[item[0]][labels_names[j]]?>?0:
????????????????????score?+=?(item[1]?-?users_average_scores_list[i])
????????????????????count?+=?1

????????????#?如果求出的值太小,直接置0
????????????if?abs(score)?????????????????score?=?0.0
????????????if?count?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-01?11:15??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\
?????文件????????9855??2018-11-01?10:16??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\content_based_recommend.py
?????文件????????5690??2018-11-01?11:11??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\mix_user_cb.py
?????文件????????5007??2018-11-01?08:49??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\temp_movies_01mat.csv
?????文件????????3259??2018-11-01?08:49??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\temp_users_movies_01mat.csv
?????文件?????????717??2018-11-01?09:07??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\temp_users_rating.csv
?????文件?????????702??2018-11-01?10:45??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\temp_user_scores_mat.csv
?????文件?????????619??2018-11-01?10:46??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\temp_user_scores_mat2.csv
?????文件????????7962??2018-11-01?10:56??電視節(jié)目推薦實例完整代碼與數(shù)據(jù)\user_based_recommend.py

評論

共有 條評論

相關(guān)資源