What It Does
PriorityX helps answer a practical monitoring question: when there are hundreds of entities over time, which ones need attention first?
It uses Generalized Linear Mixed Models to estimate two scores per entity: volume, how far its baseline sits from its peers, and growth, which way its trajectory is heading. Each entity then lands in one quadrant of a 2x2 priority matrix for operational triage.
The package was built for regulatory operations, where teams needed to surface entities with rising risk patterns before they became bigger issues.
How It Works
Input. A DataFrame with an entity column, a timestamp column, and a metric column.
Scoring. The model estimates a random intercept and a random slope per entity, accounting for repeated observations.
Matrix. Each entity lands in one quadrant based on those two scores.
The Matrix
| Growth flat or falling | Growth rising | |
|---|---|---|
| Volume above peers | Q4 Low Priority: persistent baseline | Q1 Critical: immediate attention |
| Volume below peers | Q3 Monitor: routine tracking | Q2 Investigate: emerging issue |
Q1 additionally requires a minimum observation count, so a small sample cannot land an entity in the top quadrant on noise alone.
Why GLMM
Simple averages hide movement. An entity with moderate volume but a sharply rising trend may need attention before a chronic issue that has plateaued.
The two scores come from different parts of the same model:
- x_score, the random intercept: the entity’s baseline volume relative to its peers
- y_score, the random slope: its growth trajectory relative to its peers
Scores are relative to the population, not absolute. Under a Poisson fit they are on the log scale, so 0.5 means roughly 65% above average; under Gaussian or Gamma fits they are z-standardized so different metrics stay comparable.
Try It
pip install priorityx
import pandas as pd
import priorityx as px
df = pd.read_csv("data.csv")
results = px.fit_priority_matrix(
df,
entity_col="service",
timestamp_col="date",
temporal_granularity="quarterly",
)
px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
Real Use
Consumer protection: surface investment products whose complaint volume is climbing.
Service reliability: rank endpoints by incident volume and trend.
Supply chain: detect supplier deterioration before failure becomes visible in aggregate averages.
Policy evaluation: compare regional improvement or regression after an intervention.