【问题标题】:Recommendation based on Item History基于项目历史的推荐
【发布时间】:2015-04-20 05:11:44
【问题描述】:

我有以下格式的 csv 文件/表格数据,

UserId Item1 Item2                  
1      url1   url3                                                                                     
1      url4   url6            
2      url2   url3         
2      url2   url4      
2      url4   url6     
3      url4   url6     
3      url2   url3      

因此,如果 item1 的值已知,我想在这里为特定用户预测 item2。我们可以使用协同过滤吗?如果是,请指导:)

【问题讨论】:

  • 到目前为止您所描述的可能是一个简单的数据库查询。 SELECT item2, count(*) FROM table WHERE item1 = '...' GROUP BY item2 ORDER BY COUNT(*)。你还有数据吗?用户是否对项目进行投票/评分?
  • No extra Data :( 但是可以有额外的列,给出在 item1 之后访问 item2 的次数。不使用简单数据库查询的原因是,我想找出相似的用户并相应地推荐item2(我只是想试试这个不知道它是否有效)。

标签: recommendation-engine collaborative-filtering


【解决方案1】:

我相信它会起作用,您只需要弄清楚如何确定用户是否相似。以下内容根据 item2 值与 item1s 配对(反之亦然)为您提供了一个建议字段 - 它不包括用户已经拥有的项目。当然您可以做更复杂的事情,但这里有一些东西可以开始

select *, ISNULL((SELECT STUFF
            ((SELECT ', ' + CAST(ITEM2 AS VARCHAR(10)) [text()] from
                    ((select top 5 ISNULL(item2,'') item2, count(item2) as cnt from items as CountTable1 where item1=Res.item1 and item2 is not null and len(item2) > 0
                     and item2 not in (select item2 from items where id=Res.id UNION select item1 from items where id=Res.id)
                    group by item2 order by cnt desc)
                    UNION
                    /* Below includes suggestions from item1 */
                    (select top 5 ISNULL(item1,'') item1, count(item1) as cnt from items as CountTable2 where item2=Res.item1 and item1 is not null and len(item1) > 0
                     and item1 not in (select item1 from items where id=Res.id UNION select item2 from items where id=Res.id)
                    group by item1 order by cnt desc))
                as Suggs where item1=Res.item1 FOR XML PATH('')
                , TYPE)
            .value('.','NVARCHAR(MAX)'),1,2,' ')
        List_Output)
    ,'') as Suggestions from items as Res

Sql Fiddle

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 2016-09-19
    相关资源
    最近更新 更多