【笔记2】推荐算法中的数据格式

简介: 设计推荐算法时,首先要考虑数据格式。由于数据是关于用户对商品的评分,其具有三个要素:用户、商品、评分所以,数据格式有三种形式:1. json格式(json文本)#数据格式:json数据(用户、商品、打分)json_txt = '''{"Angelica": {"Blues Traveler": 3.

设计推荐算法时,首先要考虑数据格式。

由于数据是关于用户对商品的评分,其具有三个要素:用户商品评分

所以,数据格式有三种形式:

1. json格式(json文本)

#数据格式:json数据(用户、商品、打分)
json_txt = '''{"Angelica": {"Blues Traveler": 3.5, "Broken Bells": 2.0,
                      "Norah Jones": 4.5, "Phoenix": 5.0,
                      "Slightly Stoopid": 1.5,
                      "The Strokes": 2.5, "Vampire Weekend": 2.0},
         
         "Bill":{"Blues Traveler": 2.0, "Broken Bells": 3.5,
                 "Deadmau5": 4.0, "Phoenix": 2.0,
                 "Slightly Stoopid": 3.5, "Vampire Weekend": 3.0},
         
         "Chan": {"Blues Traveler": 5.0, "Broken Bells": 1.0,
                  "Deadmau5": 1.0, "Norah Jones": 3.0, "Phoenix": 5,
                  "Slightly Stoopid": 1.0},
         
         "Dan": {"Blues Traveler": 3.0, "Broken Bells": 4.0,
                 "Deadmau5": 4.5, "Phoenix": 3.0,
                 "Slightly Stoopid": 4.5, "The Strokes": 4.0,
                 "Vampire Weekend": 2.0},
         
         "Hailey": {"Broken Bells": 4.0, "Deadmau5": 1.0,
                    "Norah Jones": 4.0, "The Strokes": 4.0,
                    "Vampire Weekend": 1.0},
         
         "Jordyn":  {"Broken Bells": 4.5, "Deadmau5": 4.0,
                     "Norah Jones": 5.0, "Phoenix": 5.0,
                     "Slightly Stoopid": 4.5, "The Strokes": 4.0,
                     "Vampire Weekend": 4.0},
         
         "Sam": {"Blues Traveler": 5.0, "Broken Bells": 2.0,
                 "Norah Jones": 3.0, "Phoenix": 5.0,
                 "Slightly Stoopid": 4.0, "The Strokes": 5.0},
         
         "Veronica": {"Blues Traveler": 3.0, "Norah Jones": 5.0,
                      "Phoenix": 4.0, "Slightly Stoopid": 2.5,
                      "The Strokes": 3.0}
}'''

2. 矩阵格式(csv文本)

横轴是商品,纵轴是用户,表内是评分

#数据格式:矩阵(用户-商品)(适用于小数据量)
csv_txt = '''"user","Blues Traveler","Broken Bells","Deadmau5","Norah Jones","Phoenix","Slightly Stoopid","The Strokes","Vampire Weekend"
"Angelica",3.5,2.0,,4.5,5.0,1.5,2.5,2.0
"Bill",2.0,3.5,4.0,,2.0,3.5,,3.0
"Chan",5.0,1.0,1.0,3.0,5,1.0,,
"Dan",3.0,4.0,4.5,,3.0,4.5,4.0,2.0
"Hailey",,4.0,1.0,4.0,,,4.0,1.0
"Jordyn",,4.5,4.0,5.0,5.0,4.5,4.0,4.0
"Sam",5.0,2.0,,3.0,5.0,4.0,5.0,
"Veronica",3.0,,,5.0,4.0,2.5,3.0,'''

3. 条目格式(csv文本)

每一行代表一条记录,其形式为:用户,商品,打分

#数据格式:条目(用户、商品、打分)(避免巨型稀疏矩阵)
csv_txt = '''"Angelica","Blues Traveler",3.5
"Angelica","Broken Bells",2.0
"Angelica","Norah Jones",4.5
"Angelica","Phoenix",5.0
"Angelica","Slightly Stoopid",1.5
"Angelica","The Strokes",2.5
"Angelica","Vampire Weekend",2.0
"Bill","Blues Traveler",2.0
"Bill","Broken Bells",3.5
"Bill","Deadmau5",4.0
"Bill","Phoenix",2.0
"Bill","Slightly Stoopid",3.5
"Bill","Vampire Weekend",3.0
"Chan","Blues Traveler",5.0
"Chan","Broken Bells",1.0
"Chan","Deadmau5",1.0
"Chan","Norah Jones",3.0
"Chan","Phoenix",5,
"Chan","Slightly Stoopid",1.0
"Dan","Blues Traveler",3.0
"Dan","Broken Bells",4.0
"Dan","Deadmau5",4.5
"Dan","Phoenix",3.0
"Dan","Slightly Stoopid",4.5
"Dan","The Strokes",4.0
"Dan","Vampire Weekend",2.0
"Hailey","Broken Bells",4.0
"Hailey","Deadmau5",1.0
"Hailey","Norah Jones",4.0
"Hailey","The Strokes",4.0
"Hailey","Vampire Weekend",1.0
"Jordyn","Broken Bells",4.5
"Jordyn","Deadmau5",4.0
"Jordyn","Norah Jones",5.0
"Jordyn","Phoenix",5.0
"Jordyn","Slightly Stoopid",4.5
"Jordyn","The Strokes",4.0
"Jordyn","Vampire Weekend",4.0
"Sam","Blues Traveler",5.0
"Sam","Broken Bells",2.0
"Sam","Norah Jones",3.0
"Sam","Phoenix",5.0
"Sam","Slightly Stoopid",4.0
"Sam","The Strokes",5.0
"Veronica","Blues Traveler",3.0
"Veronica","Norah Jones",5.0
"Veronica","Phoenix",4.0
"Veronica","Slightly Stoopid",2.5
"Veronica","The Strokes",3.0'''
目录
相关文章
|
数据采集 分布式计算 编译器
利用Pholcus框架提取小红书数据的案例分析
利用Pholcus框架提取小红书数据的案例分析
|
3月前
|
机器学习/深度学习 数据采集 搜索推荐
用python实现基于用户行为的内容推荐系统
用python实现基于用户行为的内容推荐系统
76 8
|
5月前
|
搜索推荐 算法 大数据
基于内容的推荐系统算法详解
【7月更文挑战第14天】基于内容的推荐系统算法作为推荐系统发展的初期阶段的重要技术之一,具有其独特的优势和广泛的应用场景。然而,随着大数据和人工智能技术的发展,传统的基于内容的推荐系统已经难以满足日益复杂和多样化的推荐需求。因此,未来的推荐系统研究将更加注重多种推荐算法的融合与创新,以提供更加精准、个性化的推荐服务。
|
搜索推荐 NoSQL Redis
149 混合推荐系统案例(功能分析)
149 混合推荐系统案例(功能分析)
92 0
|
7月前
|
机器学习/深度学习
R语言使用Rasch模型分析学生答题能力
R语言使用Rasch模型分析学生答题能力
|
7月前
|
存储 数据可视化 数据挖掘
【数据分析与可视化】时间序列基础讲解与实战(图文解释 附源码)
【数据分析与可视化】时间序列基础讲解与实战(图文解释 附源码)
83 0
|
存储 NoSQL 数据库
如何使用图形数据库构建实时推荐引擎
“您可能还喜欢”是一个简单的短语,暗示了企业与客户互动和联系方式的新时代,图形数据库可以轻松帮助构建推荐引擎。
83 0
|
机器学习/深度学习 存储 自然语言处理
# 【推荐系统】:协同过滤和基于内容过滤概述
# 【推荐系统】:协同过滤和基于内容过滤概述
# 【推荐系统】:协同过滤和基于内容过滤概述
|
存储 缓存 自然语言处理
推荐系统[一]:超详细知识介绍,一份完整的入门指南,解答推荐系统相关算法流程、衡量指标和应用,以及如何使用jieba分词库进行相似推荐
推荐系统[一]:超详细知识介绍,一份完整的入门指南,解答推荐系统相关算法流程、衡量指标和应用,以及如何使用jieba分词库进行相似推荐
推荐系统[一]:超详细知识介绍,一份完整的入门指南,解答推荐系统相关算法流程、衡量指标和应用,以及如何使用jieba分词库进行相似推荐
|
SQL 分布式计算 算法
推荐引擎RecEng基本操作演示|学习笔记
快速学习推荐引擎RecEng基本操作演示
199 0
推荐引擎RecEng基本操作演示|学习笔记