融合动态权重与抗刷机制的网文评分系统——基于优书网、IMDB与Reddit的混合算法实践

✨ Yumuing 博客

🚀 探索技术的每一个角落,解码世界的每一种可能!

💌 如果你对 AI 充满好奇,欢迎关注博主,订阅专栏,让我们一起开启这段奇妙的旅程!

以权威用户为核心,时间衰减为尺度,社区互动为杠杆」的评分体系,实现:

📌 动态防刷:实时监控异常点赞,自动降权可疑评价

📌 智能冷启动:新书享3个月权重保护期,新用户默认60%权威值

📌 时空平衡:3年半衰期机制+Reddit热榜公式,兼顾经典与时效性

评分计算公式

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> S = ∑ i = 1 n ( w i ⋅ s i ) + C ⋅ μ ∑ i = 1 n w i + C S = \frac{\sum_{i=1}^{n} (w_i \cdot s_i)+C\cdot \mu}{\sum_{i=1}^{n} w_i+C} </math>S=∑i=1nwi+C∑i=1n(wi⋅si)+C⋅μ

其中:

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> S S </math>S:最终综合评分

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> s i s_i </math>si:第i条评价的原始评分(1-5星)

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> w i w_i </math>wi:第i条评价的综合权重

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ:所有书籍的基准平均分(动态计算),采用以评分人数为权重的优书网原始加权平均评分(5.269分)

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> C C </math>C:平滑强度系数

    推荐值取平均评论数的50%,为小样本添加该值对应数量的平均评价 注:女频若是普遍高于男频,则采用男女频分类排行,再重新赋值,混合排行

权重计算模型

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> w i = ( A i ⋅ T i ⋅ V i ) w_i = (A_i \cdot T_i \cdot V_i) </math>wi=(Ai⋅Ti⋅Vi)

评价者权重计算

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> A i = log ⁡ ( 1 + h a h a v g ) 1 + log ⁡ ( 1 + h a h a v g ) ⋅ s i g m o i d ( h a − h a v g h s t d ) A_i =\frac {\log(1 + \frac{h_a}{h_{avg}})}{1+\log(1 + \frac{h_a}{h_{avg}}) } \cdot sigmoid(\frac{h_a - h_{avg}}{h_{std}}) </math>Ai=1+log(1+havgha)log(1+havgha)⋅sigmoid(hstdha−havg)

其中:

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> h a h_a </math>ha:评价者历史评论总赞同数
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> h a v g h_{avg} </math>havg:平台用户历史赞同数平均值
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> h s t d h_{std} </math>hstd:平台用户历史赞同数标准差

设计原理:

  • 使用自然对数 <math xmlns="http://www.w3.org/1998/Math/MathML"> e \mathrm{e} </math>e压缩防止头部用户主导
  • Sigmoid函数实现平滑过渡,当用户权威值超过均值1个标准差时获得0.73权重,2个标准差时达0.88

时间衰减因子

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> T i = e − λ ⋅ Δ t T_i = e^{-\lambda \cdot \Delta t} </math>Ti=e−λ⋅Δt

其中:

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> Δ t \Delta t </math>Δt:当前时间与评价时间的差值(以月为单位)
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> λ \lambda </math>λ:衰减系数

示例效果:推荐值为0.02,半衰期为3年

  • 1月前评价:0.98
  • 1年前评价:0.79
  • 3年前评价:0.56

社区反馈权重

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> V i = 1 2 ( v i v m a x + v i v i + v q ) V_i =\frac{1}{2}(\sqrt{\frac{v_i}{v_{max}}} + \frac{v_i}{v_i + v_{q}}) </math>Vi=21(vmaxvi +vi+vqvi)

其中:

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> v i v_i </math>vi:该评价被赞同数
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> v m a x v_{max} </math>vmax:当前书籍的最高单条评价赞同数
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> v q v_q </math>vq:抗噪调节参数(推荐取10)

设计原理:

  • 第一项保证头部评价的显著性
  • 第二项防止零赞同评价被完全忽视

算法说明

  1. 动态适应性:

    1. 每小时自动更新 <math xmlns="http://www.w3.org/1998/Math/MathML"> h a v g h_{avg} </math>havg和 <math xmlns="http://www.w3.org/1998/Math/MathML"> h s t d h_{std} </math>hstd
    2. 每天更新 <math xmlns="http://www.w3.org/1998/Math/MathML"> v m a x v_{max} </math>vmax值
    3. 每月重新计算所有 <math xmlns="http://www.w3.org/1998/Math/MathML"> Δ t \Delta t </math>Δt
  2. 鲁棒性保障:

    设置权重下限 <math xmlns="http://www.w3.org/1998/Math/MathML"> w m i n = 0.2 w_{min}=0.2 </math>wmin=0.2防止过度衰减

    对刷赞行为设置 <math xmlns="http://www.w3.org/1998/Math/MathML"> v i v_i </math>vi上限(如当日突增超均值3σ,则动态降低到该书评计算得出社区权重的20%)

  3. 冷启动方案:

    新用户默认 <math xmlns="http://www.w3.org/1998/Math/MathML"> A i = 0.6 A_i=0.6 </math>Ai=0.6

    新书籍首月时间递减参数 <math xmlns="http://www.w3.org/1998/Math/MathML"> λ \lambda </math>λ降为0.01,三个月后改为0.02

    起始平均分 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ选取优书网所有书籍加权平均 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ = ∑ i = 1 n 该书籍评价人数 所有评价人数 ⋅ 该书籍评分 ∑ i = 1 n 该书籍评价人数 所有评价人数 \mu=\frac{\sum_{i=1}^{n}\frac{该书籍评价人数}{所有评价人数} \cdot 该书籍评分}{\sum_{i=1}^{n}\frac{该书籍评价人数}{所有评价人数}} </math>μ=∑i=1n所有评价人数该书籍评价人数∑i=1n所有评价人数该书籍评价人数⋅该书籍评分

最终分数映射

<math xmlns="http://www.w3.org/1998/Math/MathML"> N x = N max ⁡ − N min ⁡ O max ⁡ − O min ⁡ × ( O x − O min ⁡ ) + N min ⁡ N_{x}=\frac{N_{\max}-N_{\min}}{O_{\max}-O_{\min}}\times(O_{x}-O_{\min})+N_{\min}\quad </math>Nx=Omax−OminNmax−Nmin×(Ox−Omin)+Nmin

其中:

  • <math xmlns="http://www.w3.org/1998/Math/MathML"> N m a x = 10 N_{max}=10 </math>Nmax=10
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> N m i n = 1 N_{min}=1 </math>Nmin=1
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> O m a x = 5 O_{max}=5 </math>Omax=5
  • <math xmlns="http://www.w3.org/1998/Math/MathML"> O m i n = 1 O_{min}=1 </math>Omin=1

即: <math xmlns="http://www.w3.org/1998/Math/MathML"> N x = 9 4 × ( O x − 1 ) + 1 N_{x}=\frac{9}{4}\times(O_{x}-1)+1 </math>Nx=49×(Ox−1)+1

注:保留两位小数,少于二十人评分建议不显示

点赞和点踩说明

  • 点赞和踩都得花费签到得到的代币,最终显示赞值(负值显示为0,保留值)为: <math xmlns="http://www.w3.org/1998/Math/MathML"> 点赞量 − 点踩量 点赞量-点踩量 </math>点赞量−点踩量
  • 首页书评排名算法:Reddit 排名算法

算法说明

<math xmlns="http://www.w3.org/1998/Math/MathML"> s c o r e = l o g 10 ( z ) + ( y ⋅ t 45000 ) score= log_{10}(z) + (\frac {y \cdot t} {45000}) </math>score=log10(z)+(45000y⋅t)

其中:

  • t = 发帖时间 - 2005年12月8日7:46:43

    Reddit用发帖时间与成立时间的差值来表示t,单位为秒。帖子越新,t值越大,得分就越高。因此,最新的帖子相对较旧的帖子有更高的排名优先权。

  • x = 赞成票 - 反对票

    这个值反映了帖子总体的支持度。显然,赞成票多于反对票的帖子更容易排在前列。

  • y = +1 或 -1

    如果赞成票多于反对票,y取+1,反之则取-1,代表帖子是否整体受欢迎。

  • z = |赞成票 - 反对票|

    受欢迎程度反映了投票差的绝对值,即z越大,表示帖子越受欢迎或越被厌恶。



相关推荐
Asthenia04121 小时前
为什么说MVCC无法彻底解决幻读的问题?
后端
Asthenia04121 小时前
面试官问我:三级缓存可以解决循环依赖的问题,那两级缓存可以解决Spring的循环依赖问题么?是不是无法解决代理对象的问题?
后端
Asthenia04121 小时前
面试复盘:使用 perf top 和火焰图分析程序 CPU 占用率过高
后端
Asthenia04121 小时前
面试复盘:varchar vs char 以及 InnoDB 表大小的性能分析
后端
Asthenia04121 小时前
面试问题解析:InnoDB中NULL值是如何记录和存储的?
后端
Asthenia04121 小时前
面试官问我:TCP发送到IP存在但端口不存在的报文会发生什么?
后端
Asthenia04121 小时前
HTTP 相比 TCP 的好处是什么?
后端
Asthenia04121 小时前
MySQL count(*) 哪个存储引擎更快?为什么 MyISAM 更快?
后端
Asthenia04121 小时前
面试官问我:UDP发送到IP存在但端口不存在的报文会发生什么?
后端
Asthenia04121 小时前
深入理解 TCP backlog 参数:意义、应用场景与 Netty 中的应用
后端