用户网站访问行为预测-----Nupic算法简单Demo

之前介绍了两篇Nupic的技术细节—-脑皮层学习算法 —nupic的深入学习(一)脑皮层学习算法 —nupic的深入学习(二),但缺少了利用Nupic的具体实例。这篇文章会利用Nupic算法,基于已有的用户访问网站类别数据,预测用户的访问网站的类别。


1. 数据说明

数据,代码都在Github上。可下载。
列表中的元素就是网站类别

PAGE_CATEGORIES = [
  "frontpage", "news", "tech", "local", "opinion", "on-air", "misc", "weather",
  "msn-news", "health", "living", "business", "msn-sports", "sports", "summary",
  "bbs", "travel"
]

下面就是算法要读取的数据(msnbc990928.zip)

% Different categories found in input file:

frontpage news tech local opinion on-air misc weather msn-news health living business msn-sports sports summary bbs travel


% Sequences:

1 1 
2 
3 2 2 4 2 2 2 3 3 
5 
1 
6 
1 1 
6 
6 7 7 7 6 6 8 8 8 8 
6 9 4 4 4 10 3 10 5 10 4 4 4 
1 1 1 11 1 1 1 
12 12 

数据序列中,每行代表一个用户的点击情况,比如第一行,用户先点击了frontpage 1次,然后点击了news 1次,算法要做的工作是,基于已有的用户点击行为,预测下一刻用户的点击行为。

2.算法运行

Github上下载源码,运行

python webdata.py

算法会完成所有操作,结果会打印在控制台。

3.算法代码解析

算法分为两个架构:1.配置神经网络各个组件的参数;2.依次读取单个用户的数据,训练算法;3. 利用算法预测
分步骤讲述如下:
(一) 配置神经网络各个组件的参数

#网页的类别
# List of page categories used in the dataset
PAGE_CATEGORIES = [
  "frontpage", "news", "tech", "local", "opinion", "on-air", "misc", "weather",
  "msn-news", "health", "living", "business", "msn-sports", "sports", "summary",
  "bbs", "travel"
]

#配置编码器,这里利用SDRCategoryEncoder
# Configure the sensor/input region using the "SDRCategoryEncoder" to encode
# the page category into SDRs suitable for processing directly by the TM
SENSOR_PARAMS = {
  "verbosity": 0,
  "encoders": {
    "page": {
      "fieldname": "page",
      "name": "page",
      "type": "SDRCategoryEncoder",
      # The output of this encoder will be passed directly to the TM region,
      # therefore the number of bits should match TM's "inputWidth" parameter
      "n": 1024,
      # Use ~2% sparsity
      "w": 21
    },
  },
}

#配置时间池组件,使算法有学习功能的组件
# Configure the temporal memory to learn a sequence of page SDRs and make
# predictions on the next page of the sequence.
TM_PARAMS = {
  "seed": 1960,
  # Use "nupic.bindings.algorithms.TemporalMemoryCPP" algorithm
  "temporalImp": "tm_cpp",
  # Should match the encoder output
  "inputWidth": 1024,
  "columnCount": 1024,
  # Use 1 cell per column for first order prediction.
  # Use more cells per column for variable order predictions.
  "cellsPerColumn": 1,
}

#配置Classifier组件,使得算法能够输出预测的网站类别
# Configure the output region with a classifier used to decode TM SDRs back
# into pages
CL_PARAMS = {
  "implementation": "cpp",
  "regionName": "SDRClassifierRegion",
  # alpha parameter controls how fast the classifier learns/forgets. Higher
  # values make it adapt faster and forget older patterns faster.
  "alpha": 0.001,
  "steps": 1,
}

#将所有的参数组合在一起,构成完成的Model
#顺序是# page => [encoder] => [TM] => [classifier] => prediction
# Create a simple HTM network that will receive the current page as input, pass
# the encoded pag
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
京东JDdata算法大赛-高潜用户购买意向预测是一个以数据挖掘和机器学习为基础的竞赛项目,其目标是通过分析京东平台上的用户行为数据,预测用户对商品的购买意向。通过这个比赛,京东希望能够进一步提高用户购买转化率,提升用户的购物体验。 在比赛中,参赛者需要利用提供的京东用户行为数据,如用户的购物记录、浏览记录、搜索记录等,以及商品的相关信息,通过建立有效的模型,预测用户是否有购买某种商品的意向。这个预测结果对于京东来说具有重要意义,可以帮助京东优化推荐系统,提供更为个性化的商品推荐,从而吸引更多的用户进行购买。 为了参赛者能够更好地完成这个任务,京东提供了大量的数据和工具。参赛者可以自由使用这些数据和工具进行分析和建模,并提交预测结果。在整个比赛过程中,参赛者可以通过不断地调整模型参数和特征工程,提升模型的预测能力。 参与这个比赛可以带来很多好处。首先,参赛者可以通过实践学习数据挖掘和机器学习的相关知识和技术,提高自己在这个领域的能力。其次,通过分析京东平台上的数据,参赛者可以深入了解用户的消费习惯,洞察用户的购买行为,为企业提供有价值的业务洞见。最后,成功的参赛者还有机会获得丰厚的奖金和荣誉,进一步提升个人的社会影响力。 总之,京东JDdata算法大赛-高潜用户购买意向预测是一个很有意义的竞赛项目,对于参赛者和京东来说都具有重要的价值。通过这个比赛,可以促进数据挖掘和机器学习技术的发展,提升京东的推荐系统,为用户提供更好的购物体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值