当前位置:网站首页>02_电影推荐(ContentBased)_用户画像
02_电影推荐(ContentBased)_用户画像
2022-07-17 05:04:00 【Big data达闻西】
基于内容的电影推荐:用户画像
用户画像构建步骤:
- 根据用户的评分历史,结合物品画像,将有观影记录的电影的画像标签作为初始标签反打到用户身上
- 通过对用户观影标签的次数进行统计,计算用户的每个初始标签的权重值,排序后选取TOP-N作为用户最终的画像标签
用户画像建立
import pandas as pd
import numpy as np
from gensim.models import TfidfModel
from functools import reduce
import collections
from pprint import pprint
# ......
''' user profile画像建立: 1. 提取用户观看列表 2. 根据观看列表和物品画像为用户匹配关键词,并统计词频 3. 根据词频排序,最多保留TOP-k个词,这里K设为100,作为用户的标签 '''
def create_user_profile():
watch_record = pd.read_csv("datasets/ml-latest-small/ratings.csv", usecols=range(2), dtype={
"userId":np.int32, "movieId": np.int32})
watch_record = watch_record.groupby("userId").agg(list)
# print(watch_record)
movie_dataset = get_movie_dataset()
movie_profile = create_movie_profile(movie_dataset)
user_profile = {
}
for uid, mids in watch_record.itertuples():
record_movie_prifole = movie_profile.loc[list(mids)]
counter = collections.Counter(reduce(lambda x, y: list(x)+list(y), record_movie_prifole["profile"].values))
# 兴趣词
interest_words = counter.most_common(50)
maxcount = interest_words[0][1]
interest_words = [(w,round(c/maxcount, 4)) for w,c in interest_words]
user_profile[uid] = interest_words
return user_profile
user_profile = create_user_profile()
pprint(user_profile)
边栏推荐
- Construction and application of knowledge atlas de (V): knowledge reasoning
- Differences between substr and substring in JS
- ModelArts第二次培训笔记
- FanoutExchange交换机简单使用
- 畢設:基於Vue+Socket+Redis的分布式高並發防疫健康管理系統
- 负载均衡添加ssl证书
- String字符串根据符号进行特殊截取处理
- 数据库取配置文件字段,然后进行数据处理和判断
- Cve-2021-44228 log4j reproduction and principle
- Es document operation
猜你喜欢
sleuth入门
Restclient operation document
HarmonyOS第三次培训笔记
CVE-2022-23131 Zabbix SAML SSO认证绕过漏洞
HarmonyOS第二次培训笔记
[email protected] : `node install. Problems of js`"/>
solve [email protected] : `node install. Problems of js`
HarmonyOS第四次培训笔记
CVE-2021-44228 Log4j 复现及原理
Harmonyos入门
Cve-2019-14234 Django jsonfield SQL injection vulnerability
随机推荐
数据库实训7【索引与数据完整性约束的创建】
pygame-飞机大战1.0(步骤+窗口无响应问题)
Embrace declarative UI
md5 密码加密
POC——DVWA‘s XSS Reflected
ThreadLocal线程安全示例及其原理
3.RestClient查询文档
Flask的使用
Wechat docking mechanism memo
POC——DVWA‘s File Upload
The difference between junit4 and junit5
负载均衡添加ssl证书
Differences and precautions of fastjson, jackjson and gson
Es document operation
Implementation idea of log adding to database
游玩数据获取与数据分析、数据挖掘 【2022.5.30】
mysql优化
浅聊全局过滤器
Harmonyos third training notes
加密和解密