博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业
毕业设计
项目实战6年之久,选择我们就是选择放心、选择安心毕业✌感兴趣的可以先收藏起来,点赞、关注不迷路✌
毕业设计:2023-2024年计算机毕业设计1000套(建议收藏)
毕业设计:2023-2024年最新最全计算机专业毕业设计选题汇总
1、项目介绍
技术栈:
Python语言、Django框架、基于用户协同过滤推荐算法、菜品做法、HTML
2、项目界面
(1)最新美食推荐
(2)美食详情
(3)用户评价评分
(4)美食分类、美食一览
(5)后台数据管理
(6)美食评论
3、项目说明
美食推荐系统是基于用户协同过滤推荐算法的应用程序,使用Python语言和Django框架开发。推荐系统的目标是根据用户的偏好和历史行为,为其提供个性化的美食推荐。
系统主要包括以下功能:
-
用户注册和登录:用户可以通过注册账户来使用推荐系统,并通过登录来保存和获取个人的推荐结果。
-
用户偏好收集:系统会收集用户对不同菜品的偏好信息,包括评分、收藏等,用于推荐算法的计算。
-
推荐算法:系统采用基于用户协同过滤的推荐算法来生成个性化的推荐结果。该算法会根据用户的历史行为和其他用户的行为进行相似度计算,从而找到相似用户的喜好,并为用户推荐相似用户喜欢的美食。
-
菜品做法展示:系统会提供菜品的详细信息和做法,包括菜品图片、材料、步骤等,以帮助用户更好地了解和制作菜品。
-
用户反馈和评价:用户可以对推荐的菜品进行评价和反馈,系统会根据用户的反馈不断优化推荐结果。
-
界面设计:系统使用HTML来设计用户友好的界面,使用户能够方便地浏览和操作。
通过以上功能,美食推荐系统可以为用户提供个性化的美食推荐,帮助他们发现和尝试新的菜品,提升用户的用餐体验。
4、核心代码
from math import sqrt,pow
import operator
class UserCf():
#获得初始化数据
def __init__(self,data):
self.data=data
#通过用户名获得美食列表,仅调试使用
def getItems(self,username1,username2):
return self.data[username1],self.data[username2]
#计算两个用户的皮尔逊相关系数
def pearson(self,user1,user2): #数据格式为:美食,评分 {'Snakes on a Plane': 4.5, 'You, Me and Dupree': 1.0, 'Superman Returns': 4.0}
sumXY=0.0
n=0
sumX=0.0
sumY=0.0
sumX2=0.0
sumY2=0.0
try:
for movie1,score1 in user1.items():
if movie1 in user2.keys():#计算公共的美食的评分
n+=1
sumXY+=score1*user2[movie1]
sumX+=score1
sumY+=user2[movie1]
sumX2+=pow(score1,2)
sumY2+=pow(user2[movie1],2)
molecule=sumXY-(sumX*sumY)/n
denominator=sqrt((sumX2-pow(sumX,2)/n)*(sumY2-pow(sumY,2)/n))
r=molecule/denominator
except Exception:
print("异常信息")
return None
return r
#计算与当前用户的距离,获得最临近的用户
def nearstUser(self,username,n=1):
distances={}#用户,相似度
for otherUser,items in self.data.items():#遍历整个数据集
if otherUser not in username:#非当前的用户
distance=self.pearson(self.data[username],self.data[otherUser])#计算两个用户的相似度
if distance is None:
distance = 0
distances[otherUser]=distance
sortedDistance=sorted(distances.items(),key=operator.itemgetter(1),reverse=True)#最相似的N个用户
print("排序后的用户为:"+ str(sortedDistance))
return sortedDistance[:n]
#给用户推荐美食
def recomand(self,username,n=1):
recommand={}#待推荐的美食
for user,score in dict(self.nearstUser(username,n)).items():#最相近的n个用户
print("推荐的用户:%s,分数:%s"%(user,score))
for movies,scores in self.data[user].items():#推荐的用户的美食列表
if movies not in self.data[username].keys():#当前username没有看过
# print("%s为该用户推荐的美食:%s"%(user,movies))
if movies not in recommand.keys():#添加到推荐列表中
recommand[movies]=scores
return sorted(recommand.items(),key=operator.itemgetter(1),reverse=True)#对推荐的结果按照美食评分排序
if __name__=='__main__':
users = {'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}
}
userCf=UserCf(data=users)
recommandList=userCf.recomand('Toby', 2)
print("最终推荐:")
for r in recommandList:
print(r)
????✌
感兴趣的可以先收藏起来,点赞关注不迷路,想学习更多项目可以查看主页,大家在毕设选题,项目代码以及论文编写等相关问题都可以给我留言咨询,希望可以帮助同学们顺利毕业!
????✌
5、源码获取方式
????
由于篇幅限制,获取完整文章或源码、代做项目的,拉到文章底部即可看到个人联系方式。
????
点赞、收藏、关注,不迷路,
下方查看
????????
获取联系方式
????????