資源簡介
源代碼和實戰非常適合初學者使用,很詳細

代碼片段和文件信息
#-*-?coding:?utf-8?-*-
#使用基于UBCF算法對電影進行推薦
from?__future__?import?print_function
import?pandas?as?pd
############????主程序???##############
if?__name__?==?“__main__“:
????print(“\n--------------使用基于UBCF算法對電影進行推薦?運行中...?-----------\n“)
????traindata?=?pd.read_csv(‘/media/dp_zhou/Knowledge/Learning?data/Python?books/數據與代碼/數據與代碼/示例程序/data/u1.base‘sep=‘\t‘?header=Noneindex_col=None)
????testdata?=?pd.read_csv(‘/media/dp_zhou/Knowledge/Learning?data/Python?books/數據與代碼/數據與代碼/示例程序/data/u1.test‘sep=‘\t‘?header=Noneindex_col=None)
????#刪除時間標簽列
????traindata.drop(3axis=1?inplace=True)
????testdata.drop(3axis=1?inplace=True)
????#行與列重新命名
????traindata.rename(columns={0:‘userid‘1:‘movid‘2:‘rat‘}?inplace=True)
????testdata.rename(columns={0:‘userid‘1:‘movid‘2:‘rat‘}?inplace=True)
????traindf=traindata.pivot(index=‘userid‘?columns=‘movid‘?values=‘rat‘)
????testdf=testdata.pivot(index=‘userid‘?columns=‘movid‘?values=‘rat‘)
????traindf.rename(index={i:‘usr%d‘%(i)?for?i?in?traindf.index}??inplace=True)
????traindf.rename(columns={i:‘mov%d‘%(i)?for?i?in?traindf.columns}??inplace=True)
????testdf.rename(index={i:‘usr%d‘%(i)?for?i?in?testdf.index}??inplace=True)
????testdf.rename(columns={i:‘mov%d‘%(i)?for?i?in?testdf.columns}??inplace=True)
????userdf=traindf.loc[testdf.index]
????#獲取預測評分和推薦列表
????trainratstrainrecomm=recomm(traindfuserdf)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-27?16:54??Python與數據挖掘\
?????文件???????33280??2018-07-29?17:48??Python與數據挖掘\《Python與數據挖掘》勘誤表?V2.6.xls
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第10章\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第10章\上機實驗\
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第10章\上機實驗\data\
?????文件?????1586544??2018-07-29?18:18??Python與數據挖掘\第10章\上機實驗\data\u1.ba
?????文件??????392629??2018-07-29?17:49??Python與數據挖掘\第10章\上機實驗\data\u1.test
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\code\
?????文件????????1560??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\code\10-1.py
?????文件????????1879??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\code\recommender.py
?????文件????????1762??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\code\recommender.pyc
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第10章\示例程序\data\
?????文件?????1586544??2018-07-29?18:18??Python與數據挖掘\第10章\示例程序\data\u1.ba
?????文件??????392629??2018-07-29?17:49??Python與數據挖掘\第10章\示例程序\data\u1.test
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第11章\
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第11章\上機實驗\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第11章\上機實驗\data\
?????文件???????22528??2018-07-29?17:49??Python與數據挖掘\第11章\上機實驗\data\dat.xls
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第11章\上機實驗\tmp\
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第11章\示例程序\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第11章\示例程序\code\
?????文件????????3668??2018-07-29?17:49??Python與數據挖掘\第11章\示例程序\code\11-1.py
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第11章\示例程序\data\
?????文件???????20480??2018-07-29?17:49??Python與數據挖掘\第11章\示例程序\data\arima_data.xls
?????目錄???????????0??2018-07-29?18:18??Python與數據挖掘\第11章\示例程序\tmp\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第2章\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第2章\上機實驗\
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第2章\上機實驗\data\
?????文件???????60655??2018-07-29?17:49??Python與數據挖掘\第2章\上機實驗\data\horseColic.txt
?????目錄???????????0??2018-07-29?17:49??Python與數據挖掘\第2章\上機實驗\tmp\
............此處省略91個文件信息
- 上一篇:數據挖掘課程設計.rar
- 下一篇:Python3學習筆記
評論
共有 條評論