Decay Score Functions for Gnus

Decay Score Functions for Gnus

For a few weeks now, I’ve been using Gnus as my MUA. The main reason for leaving Mutt is the intriguing adaptive scoring Gnus provides, which seems to be especially tailored towards people like me that read mailing lists a lot. Gnus decays non-permanent scores once a day according to modest rules applied with the gnus-decay-score function. By default, every score entry up to 60 is reduced by a constant (of 3), values greater than 60 are downscaled by 5%. This results in a (almost) linear function that deals gently with the literal scores. While there is nothing wrong with a linear function here, I’d like to restrict adaptive scoring to a certain range.

The first alternative builds on the default decay and multiplies the literal score with a factor derived from the exponentiation of the score with a negative constant. Thus the adapted score is still (almost) a linear function but shrinks output values quite a bit:

(defun gnus-decay-score-1 (score)
   (pcase score
     (`0 0)
     ((guard (< score 0)) (* score (expt (abs score) -0.2)))
     (_ (* score (expt score -0.2))))))

For comparison, the following function applies an increasing exponential decay to literal score values. This results in values that increase rapidly first, level off thereafter and essentially max out close to a defined upper limit:

(defun gnus-decay-score-2 (score)
  (let ((ulim 100)
        (exponent -0.12))
     (pcase score
       (`0 0)
       ((guard (< score 0)) (* -1 ulim (- 1 (expt (abs score) exponent))))
       (_ (* ulim (- 1 (expt score exponent))))))))

Plotting adapted scores from various decay functions for a sequence from -50 to 250, a range that encloses almost all my current score values, will reveal the differences:

set terminal svg size 720,320 enhanced font 'Lato,10'

set auto y
set xtics 25
set tics out scale 0.4 nomirror
set style line 101 lc rgb '#8c8c8c' lt 1 lw 1
set border 3 front ls 101
set xlabel 'Literal Score'
set ylabel 'Adapted Score'
set key left nobox
set termoption dash

plot dat using 1:4 with lines lc rgb '#cd00cd' lt 5 lw 1 title 'gnus-decay-score-2',\
     dat using 1:3 with lines lc 3 lt 5 lw 1 title 'gnus-decay-score-1',\
     dat using 1:2 with lines lc rgb '#228b22' lt 3 lw 1 title 'gnus-decay-score',\
     dat using 1:1 with lines lc 1 lt 1 lw 1 title 'literal score'

Sorry, your browser does not support SVG.

Figure 1: Gnus Decay Score Function Comparison
Gnus Emacs