如何修剪频率设置的数据以符合论文的描述

MovieLens数据集提供了一个包含列的表:
userid | movieid | tag | timestamp
我无法复制他们修剪用于的MovieLens数据集的方式: 标签知情协同过滤,由Zhen,Li和Young编写 在上面的4.1数据集中,它写道 “对于标记信息,我们只保留添加的标记 至少3部不同的电影。至于用户,我们只 保留那些在其中使用至少3个不同标签的用户 标记历史。对于电影,我们只保留那些电影 由至少3个不同的标签注释。“ 我试图查询数据库:
select TMP.userid, count(*) as tagnum
from (select distinct T.userid as userid, T.tag as tag from tags T) AS TMP 
group by TMP.userid
having tagnum >= 3;
我得到了一个标有3个不同标签的1760名用户的列表。但是,一些标签 未添加至少3部不同的电影。 任何帮助表示赞赏。     
已邀请:
你不是在任何地方限制每个标签的电影。看起来你应该首先丢弃至少三部电影和三个用户都没有使用过的标签。然后限制已标记三次的用户。 此查询应该为您提供由三个+用户和三个+电影标记的标记:
select T1.tag,
       (select count( distinct T2.movieid ) from tags T2 where T2.tag = T1.tag) as mcount,
       (select count( distinct T3.userid ) from tags T3 where T3.tag = T1.tag) as ucount
from tags T1
having mcount >= 3 and ucount >= 3;
如果您由用户查询,并将整个事物用作子查询,则应该能够检查也标记了三次的用户:
select T4.user, count(*) as ucount from
 (select T1.userid as user,
         (select count( distinct T2.movieid ) from tags T2 where T2.tag = T1.tag) as mcount,
         (select count( distinct T3.userid ) from tags T3 where T3.tag = T1.tag) as ucount
  from tags T1
  having mcount >= 3 and ucount >= 3) as T4
group by user
having ucount > 3;
    

要回复问题请先登录注册