博客
关于我
商品订单频繁项集数据流分析
阅读量:168 次
发布时间:2019-02-28

本文共 1253 字,大约阅读时间需要 4 分钟。

Redis中生成数据

在实际项目中,我们需要对商品之间的关系进行分析和存储。以下是基于Redis的数据生成过程:

数据生成

  • ID1 对应的商品对为:
    • (商品1, 2)
    • (商品2, 3)
    • (商品3, 4)
    • (商品4, 5)
  • ID2 对应的商品对为:
    • (商品2, 3)
    • (商品3, 3)
    • (商品4, 2)
    • (商品5, 5)
  • ID3 对应的商品对为:
    • (商品1, 2)
    • (商品2, 2)
    • (商品3, 4)
    • (商品5, 1)

数据存储

将上述商品对存储到Redis中的键 itemCounts 中:

  • (商品1, 2)
  • (商品2, 3)
  • (商品3, 3)
  • (商品4, 2)
  • (商品5, 5)
  • (商品1, 2)
  • (商品2, 2)
  • (商品3, 4)
  • (商品5, 1)

经过SplitBolt后

发射的数据为12条:

  • (ID1, 商品1, 2)
  • (ID1, 商品2, 3)
  • (ID1, 商品3, 4)
  • (ID1, 商品4, 5)
  • (ID2, 商品2, 3)
  • (ID2, 商品3, 3)
  • (ID2, 商品4, 2)
  • (ID2, 商品5, 5)
  • (ID3, 商品1, 5)
  • (ID3, 商品2, 2)
  • (ID3, 商品3, 4)
  • (ID3, 商品5, 1)

经过PairCountBolt后

Redis数据存储到键 itemCounts 中:

  • (商品1, 2) -> 2
  • (商品1, 3) -> 2
  • (商品1, 4) -> 1
  • (商品1, 5) -> 1
  • (商品2, 3) -> 3
  • (商品2, 4) -> 2
  • (商品3, 4) -> 2
  • (商品2, 5) -> 2
  • (商品3, 5) -> 2
  • (商品4, 5) -> 1

经过SupportComputeBolt后

对上述数据进行支持度计算:

  • (商品1, 2) -> 2/18
  • (商品1, 3) -> 2/18
  • (商品1, 4) -> 1/18
  • (商品1, 5) -> 1/18
  • (商品2, 3) -> 3/18
  • (商品2, 4) -> 2/18
  • (商品3, 4) -> 2/18
  • (商品2, 5) -> 2/18
  • (商品3, 5) -> 2/18
  • (商品4, 5) -> 1/18

经过ConfidenceComputeBolt后

对支持度进行置信度计算(以支持度为依据,除以对应的频率):

  • (商品1, 2) -> 2/18 ÷ 2
  • (商品1, 3) -> 2/18 ÷ 2
  • (商品1, 4) -> 1/18 ÷ 2
  • (商品1, 5) -> 1/18 ÷ 2
  • (商品2, 3) -> 3/18 ÷ 3
  • (商品2, 4) -> 2/18 ÷ 2
  • (商品3, 4) -> 2/18 ÷ 2
  • (商品2, 5) -> 2/18 ÷ 2
  • (商品3, 5) -> 2/18 ÷ 2
  • (商品4, 5) -> 1/18 ÷ 2

经过FilterBolt后

将支持度和置信度结果存储到Redis中的键 recommendedPairs 中:

  • (商品n, 商品m) -> (支持度, 置信度)

转载地址:http://biej.baihongyu.com/

你可能感兴趣的文章
python中http协议编程_HTTP编程
查看>>
python中if的效率_python中关于if-else使用性能的一点感悟
查看>>
python中import os_Python:相对导入与绝对导入(import)、os.path、__file__
查看>>
python中is和==操作符
查看>>
Python中range对象的使用以及打印九九乘法表
查看>>
Python中set.discard和set.remove方法之间的运行时差异?
查看>>
python中tkinter中value_输入字段中的python Tkinter get()值
查看>>
Python中wx.FlexGridSizer
查看>>
Python中xPath技术和BeautifulSoup的使用
查看>>
python中yield的用法详解——最简单,最清晰的解释
查看>>
python中‘set.intersection()‘的算法是什么?
查看>>
Python中一个图形中的多个绘图
查看>>
python中一个好的持久同步队列
查看>>
Python中不准确的对数
查看>>
python中什么是实例方法_在Python中创建实例方法对象的不同方法
查看>>
Python中使用cutecharts实现简单的手绘风格的图表
查看>>
python中使用dxfgrabber,解析dxf文件信息生成obj文件
查看>>
Python中使用ncmbot玩转网易云音乐
查看>>
Python中使用PIL快速实现二值图
查看>>
Python中使用PIL快速实现灰度图
查看>>