资源简介
数据挖掘课程课件+学生实验设计+基于相似性分析和用户偏好的商品推荐系统论文

代码片段和文件信息
from math import sqrt
#用户影评数据#
critics={‘Lisa Rose‘: {‘Lady in the Water‘: 2.5 ‘Snakes on a Plane‘: 3.5
‘Just My Luck‘: 3.0 ‘Superman Returns‘: 3.5 ‘You Me and Dupree‘: 2.5
‘The Night Listener‘: 3.0}
‘Gene Seymour‘: {‘Lady in the Water‘: 3.0 ‘Snakes on a Plane‘: 3.5
‘Just My Luck‘: 1.5 ‘Superman Returns‘: 5.0 ‘The Night Listener‘: 3.0
‘You Me and Dupree‘: 3.5}
‘Michael Phillips‘: {‘Lady in the Water‘: 2.5 ‘Snakes on a Plane‘: 3.0
‘Superman Returns‘: 3.5 ‘The Night Listener‘: 4.0}
‘Claudia Puig‘: {‘Snakes on a Plane‘: 3.5 ‘Just My Luck‘: 3.0
‘The Night Listener‘: 4.5 ‘Superman Returns‘: 4.0
‘You Me and Dupree‘: 2.5}
‘Mick LaSalle‘: {‘Lady in the Water‘: 3.0 ‘Snakes on a Plane‘: 4.0
‘Just My Luck‘: 2.0 ‘Superman Returns‘: 3.0 ‘The Night Listener‘: 3.0
‘You Me and Dupree‘: 2.0}
‘Jack Matthews‘: {‘Lady in the Water‘: 3.0 ‘Snakes on a Plane‘: 4.0
‘The Night Listener‘: 3.0 ‘Superman Returns‘: 5.0 ‘You Me and Dupree‘: 3.5}
‘Toby‘: {‘Snakes on a Plane‘:4.5‘You Me and Dupree‘:1.0‘Superman Returns‘:4.0}}
# 返回p1和p2的皮尔逊相关系数
def sim_pearson(prefsp1p2):
# 得到双方都曾评价过的物品列表
si ={}
for item in prefs[p1]:
if item in prefs[p2]: si[item]=1
# 得到列表元素的个数
n=len(si)
# 如果两者没有共同之处,则返回0
if n==0: return 1
# 对所有偏好求和
sum1=sum([prefs[p1][it] for it in si])
sum2=sum([prefs[p2][it] for it in si])
# 对所有偏好求平方和
sum1Sq=sum([pow(prefs[p1][it]2) for it in si])
sum2Sq=sum([pow(prefs[p2][it]2) for it in si])
# 求乘积之和
pSum=sum([prefs[p1][it]*prefs[p2][it] for it in si])
# 计算皮尔逊评价值
num=pSum-(sum1*sum2/n)
den=sqrt((sum1Sq-pow(sum12)/n)*(sum2Sq-pow(sum22)/n))
if den==0: return 0
r = num / den
return r
# 测试sim_pearson函数
#sim_pearson(critics ‘Lisa Rose‘ ‘Gene Seymour‘)
# 从数据字典中返回最佳的匹配者
# 返回结果的个数和相似度函数都是可选参数
def topMatches(prefspersonn=5similarity=sim_pearson):
scores=[(similarity(prefspersonother)other)
for other in prefs if other!=person]
# 对打分情况进行排序
scores.sort()
scores.reverse()
return scores[0:n]
# 测试topMatches函数
# topMatches(critics ‘Toby‘ n=3)
# 利用所有他人评价值的加权平均,为某人提供建议
def getRecommendations(prefspersonsimilarity=sim_pearson):
totals={}
simSums={}
for other in prefs:
# 不和自己比较
if other==person: continue
sim=similarity(prefspersonother)
# 忽略评价值为0或小于0的情况
if sim<=0: continue
for item in prefs[other]:
# 仅为自己还没有看过的影片进行评价
if item not in prefs[person] or prefs[person][item]==0:
# 相似度*评价值
totals.setdefault(item0)
totals[item]+=prefs[other][item]*sim
# 相似度之和
simSums.setdefault(item0)
simSums[item]+=sim
# 建立一个归一化的列表
rankings=[(total/simSums[item]item) for itemtotal in totals.items()]
# 返回经过排序的列表
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6524 2018-07-10 16:11 数据挖掘\.ipynb_checkpoints\Unti
文件 3351 2018-07-10 16:13 数据挖掘\基于相似性分析和用户偏好的商品推荐系统\code.py
文件 60627 2019-03-07 08:28 数据挖掘\基于相似性分析和用户偏好的商品推荐系统\基于相似性分析和用户偏好的商品推荐系统 (2).docx
文件 59787 2019-03-07 08:28 数据挖掘\基于相似性分析和用户偏好的商品推荐系统\基于相似性分析和用户偏好的商品推荐系统.docx
文件 1645568 2018-06-26 20:00 数据挖掘\数据挖掘实验设计.doc
目录 0 2018-12-20 09:56 数据挖掘\.ipynb_checkpoints
目录 0 2019-03-07 08:29 数据挖掘\基于相似性分析和用户偏好的商品推荐系统
目录 0 2019-03-07 08:30 数据挖掘
----------- --------- ---------- ----- ----
1775857 8
相关资源
- The direction of synaptic plasticity mediated
- Reparatory Effects of Nicotine on NMDA Recepto
- Apolipoprotein E4 Impairs in vivo Hippocampal
- Histamine excites rat lateral vestibular nucle
- Diltiazem augmented pentobarbital-induced LORR
- Fabrication and all-optical poling characteris
- 基于PCIe的FPGA动态配置设计与实现
- 修正Sway-Rocking土-结构相互作用模型的
- 毕业论文之温度传感器DS18B20(源码
- 美赛论文MCM两个word模板 论文格式 w
- 电子商务毕业设计论文
- 武汉大学本科生论文格式自动排版工
- 题库管理系统(包括11页的论文,PP
- 学籍管理信息系统系统需求分析报告
- 企业局域网毕业论文 经典
- 16x16点阵(滚动显示)论文 程序
- 网络信息安全技术 论文
- 不错的电子商务毕业论文
- 网上在线鲜花销售系统论文
- 全国电子设计大赛自动寻迹小车论文
- 计算机专业毕业论文--饲料销售管理系
- Cellular automata Model: an Adaptive Approach
- 斜带石斑鱼TLR22基因的克隆和鉴定
- Toll样受体在动脉粥样硬化炎症中的作
- 金欣口服液含药血清对呼吸道合胞病
- The Impact of ETC System on Safety Performance
- Toll样受体与抗病毒免疫
- TLR2在新生大鼠缺氧缺血性脑损伤后海
- 脑缺氧缺血增加新生大鼠海马区TLR4的
-
Differential ex
pression patterns of Toll-li
评论
共有 条评论