IntentDecayScore (intent_decay_score v1.0.0)

Copy Markdown View Source

Intent score per account with time decay (see https://www.onegtmlab.dev/glossary/intent-data).

Each signal has a weight and an age in days. It contributes weight * 0.5 ^ (age_days / half_life), so a signal that is one half-life old counts for half its weight. The account score is the sum.

Summary

Functions

Value of one signal after age_days with the given half-life (in days).

Format scores as a text table.

Parse CSV text with columns account, signal, weight, age_days into signal maps.

Score every account. Returns maps with account, score, signals and newest signal age, highest score first.

Types

signal()

@type signal() :: %{
  account: String.t(),
  signal: String.t(),
  weight: number(),
  age_days: number()
}

Functions

decayed(weight, age_days, half_life)

@spec decayed(number(), number(), number()) :: float()

Value of one signal after age_days with the given half-life (in days).

format(rows)

Format scores as a text table.

parse_csv(text)

@spec parse_csv(String.t()) :: {:ok, [signal()]} | {:error, String.t()}

Parse CSV text with columns account, signal, weight, age_days into signal maps.

score(signals, half_life)

@spec score([signal()], number()) :: [
  %{
    account: String.t(),
    score: float(),
    signals: pos_integer(),
    newest_days: number()
  }
]

Score every account. Returns maps with account, score, signals and newest signal age, highest score first.