Score decay
The classification process depends on scores that are increased and decreased as a visitor engages with a website or other digital experience. While those scores are accurate at the time they're calculated, over time, they become less accurate. Uniform compensates for that by automatically reducing stale scores over time. This is described as "decay.
With default settings, Context doesn't perform decay but it's a simple addition to the configuration to add a decay algorithm. Context comes with a simple linear decay implementation that decays scores at a linear rate the longer a visitor is inactive. With default linear decay settings of a 1-day grace period, 30-day decay duration, and 95% decay cap for example:
- Return visit in less than 1 day: no decay - within grace period
- Return visit in 16 days: decay is 50% of total score in each dimension (1 day grace + 15 days is half of 30-day default decay rate)
- Return visit in 31 days: decay is 95% of total score in each dimension (1 day grace + 30 days, decay cap 95%)
Activate linear decay#
Uniform provides a decay function that reduces a score by the same amount every time it runs. The following example demonstrates how to activate linear decay.
createLinearDecay
#
This function creates a linear decay function that can be assigned to the Context. Linear decay involves reducing a score by the same amount each day the decay runs.
The following describes how decay works over time and with continuing engagement. Consider the following settings:
Scores will decay by 10% each day (decay rate).
The most a score will decay in a day is 95% (decay cap).
Decay will start after 1 day (grace period).
Day New activity Decay Total score Notes 1 100 0 100 No decay due to grace period. 2 0 10 90 Decay is 10% of the previous day's score (100). 3 0 9 81 Decay is 10% of the previous day's score (90). 4 20 8.1 92.9 Decay is 10% of the previous day's score (81). Decay doesn't apply to the new activity score. 5 0 9.29 83.61 Decay is 10% of the previous day's score (92.9).
info
For more information on linear decay, see the package reference.
Implement custom decay#
To implement your custom decay function, simply implement a function with the following signature and set it on the Context
object initializer: decay: customDecay()
:
See full working example for Next.js in this repo.