Packages
intent_decay_score
1.0.0
Elixir library and Mix task that scores accounts from buying signals with a half-life: each signal counts at its weight and loses half its value every N days, so fresh intent outranks old intent.
Current section
Files
Jump to
Current section
Files
intent_decay_score
README.md
README.md
# intent_decay_score
An Elixir library and Mix task that turns [intent data](https://www.onegtmlab.dev/glossary/intent-data) into an account score that fades with time. Every signal has a weight
and an age in days; it counts for `weight x 0.5^(age / half-life)`, so a signal one half-life old is worth half and fresh intent outranks old intent. The account score is the
sum. Offline, no dependencies.
Built by [OneGTMLab](https://www.onegtmlab.dev/glossary/intent-data) (GTM engineering for B2B teams).
## Install
```elixir
def deps, do: [{:intent_decay_score, "~> 1.0"}]
```
## Use
```csv
account,signal,weight,age_days
Acme,pricing_page,10,0
Acme,job_post,20,14
Globex,funding,30,28
Globex,pricing_page,10,1
```
```bash
mix intent.decay signals.csv --half-life 14
```
```
account score signals newest_days
Acme 20.0 2 0
Globex 17.0 2 1
```
Acme: 10 + 20 x 0.5 = 20.0. Globex: 30 x 0.25 + 10 x 0.5^(1/14) = 17.0 (7.5 + 9.5). The half-life defaults to 14 days. From code:
```elixir
{:ok, signals} = IntentDecayScore.parse_csv(File.read!("signals.csv"))
IntentDecayScore.score(signals, 14) # [%{account: "Acme", score: 20.0, signals: 2, newest_days: 0.0}, ...]
```
A weight or age that is not a number, a negative age, a missing column or an unreadable file prints `error: ...` and exits 1; a bad option exits 2.
## Test
```bash
mix test
```
MIT licence.