priorityx 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {priorityx-0.3.0 → priorityx-0.4.0}/PKG-INFO +56 -1
  2. {priorityx-0.3.0 → priorityx-0.4.0}/README.md +55 -0
  3. {priorityx-0.3.0 → priorityx-0.4.0}/docs/priority_classification.md +1 -1
  4. {priorityx-0.3.0 → priorityx-0.4.0}/pyproject.toml +1 -1
  5. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/__init__.py +25 -4
  6. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/api.py +9 -5
  7. priorityx-0.4.0/src/priorityx/core/glmm.py +758 -0
  8. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/core/quadrants.py +11 -10
  9. priorityx-0.4.0/src/priorityx/metrics.py +397 -0
  10. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/tracking/movement.py +17 -5
  11. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/tracking/transitions.py +5 -5
  12. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/viz/matrix.py +169 -53
  13. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/viz/timeline.py +40 -6
  14. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/viz/trajectory.py +16 -12
  15. priorityx-0.4.0/tests/test_api_axes.py +90 -0
  16. {priorityx-0.3.0 → priorityx-0.4.0}/tests/test_glmm.py +77 -2
  17. priorityx-0.4.0/tests/test_metrics.py +78 -0
  18. {priorityx-0.3.0 → priorityx-0.4.0}/tests/test_movement_monthly.py +8 -11
  19. {priorityx-0.3.0 → priorityx-0.4.0}/tests/test_quadrants.py +4 -2
  20. priorityx-0.4.0/tests/test_viz_matrix.py +47 -0
  21. {priorityx-0.3.0 → priorityx-0.4.0}/uv.lock +1 -1
  22. priorityx-0.3.0/src/priorityx/core/glmm.py +0 -429
  23. {priorityx-0.3.0 → priorityx-0.4.0}/.github/workflows/release.yml +0 -0
  24. {priorityx-0.3.0 → priorityx-0.4.0}/.github/workflows/test.yml +0 -0
  25. {priorityx-0.3.0 → priorityx-0.4.0}/.gitignore +0 -0
  26. {priorityx-0.3.0 → priorityx-0.4.0}/LICENSE +0 -0
  27. {priorityx-0.3.0 → priorityx-0.4.0}/Makefile +0 -0
  28. {priorityx-0.3.0 → priorityx-0.4.0}/docs/README.md +0 -0
  29. {priorityx-0.3.0 → priorityx-0.4.0}/docs/api-reference.md +0 -0
  30. {priorityx-0.3.0 → priorityx-0.4.0}/docs/methodology.md +0 -0
  31. {priorityx-0.3.0 → priorityx-0.4.0}/docs/output_naming.md +0 -0
  32. {priorityx-0.3.0 → priorityx-0.4.0}/docs/quickstart.md +0 -0
  33. {priorityx-0.3.0 → priorityx-0.4.0}/examples/README.md +0 -0
  34. {priorityx-0.3.0 → priorityx-0.4.0}/examples/bugs/bugs_monitoring.py +0 -0
  35. {priorityx-0.3.0 → priorityx-0.4.0}/examples/incidents/incident_monitoring.py +0 -0
  36. {priorityx-0.3.0 → priorityx-0.4.0}/examples/violations/violations_monitoring.py +0 -0
  37. {priorityx-0.3.0 → priorityx-0.4.0}/scripts/version.py +0 -0
  38. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/core/__init__.py +0 -0
  39. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/core/filters.py +0 -0
  40. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/tracking/__init__.py +0 -0
  41. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/tracking/drivers.py +0 -0
  42. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/utils/__init__.py +0 -0
  43. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/utils/helpers.py +0 -0
  44. {priorityx-0.3.0 → priorityx-0.4.0}/src/priorityx/viz/__init__.py +0 -0
  45. {priorityx-0.3.0 → priorityx-0.4.0}/tests/test_drivers.py +0 -0
  46. {priorityx-0.3.0 → priorityx-0.4.0}/tests/test_transitions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: priorityx
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Entity prioritization and escalation detection using GLMM statistical models
5
5
  Project-URL: Homepage, https://github.com/okkymabruri/priorityx
6
6
  Project-URL: Repository, https://github.com/okkymabruri/priorityx
@@ -50,16 +50,71 @@ import priorityx as px
50
50
 
51
51
  df = pd.read_csv("data.csv")
52
52
 
53
+ # Default: volume x growth (single GLMM)
53
54
  results, stats = px.fit_priority_matrix(
54
55
  df,
55
56
  entity_col="service",
56
57
  timestamp_col="date",
57
58
  temporal_granularity="quarterly",
58
59
  )
60
+ # Returns: entity, x_score, y_score, count, quadrant
59
61
 
60
62
  px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
61
63
  ```
62
64
 
65
+ ### Custom Axes
66
+
67
+ ```python
68
+ # Custom Y axis: volume × resolution_days (two GLMMs)
69
+ results, _ = px.fit_priority_matrix(
70
+ df,
71
+ entity_col="service",
72
+ timestamp_col="date",
73
+ y_metric="resolution_days",
74
+ )
75
+
76
+ # Custom both axes: disputed_amount × paid_amount
77
+ results, _ = px.fit_priority_matrix(
78
+ df,
79
+ entity_col="service",
80
+ timestamp_col="date",
81
+ x_metric="disputed_amount",
82
+ y_metric="paid_amount",
83
+ )
84
+ ```
85
+
86
+ ### Composite Indices
87
+
88
+ ```python
89
+ # Add entity metrics
90
+ metrics = px.aggregate_entity_metrics(
91
+ df,
92
+ entity_col="service",
93
+ duration_start_col="opened_at",
94
+ duration_end_col="closed_at",
95
+ primary_col="exposure",
96
+ secondary_col="recovery",
97
+ )
98
+ results = results.merge(metrics, left_on="entity", right_on="service", how="left")
99
+
100
+ # Add weighted indices: RI (Risk), SQI (Service Quality), EWI (Early Warning)
101
+ results = px.add_priority_indices(
102
+ results,
103
+ volume_col="count",
104
+ growth_col="y_score",
105
+ severity_col="total_primary",
106
+ resolution_col="mean_duration",
107
+ recovery_col="secondary_to_primary_ratio",
108
+ # customize weights (default shown)
109
+ w_volume=0.4, w_growth=0.4, w_severity=0.2,
110
+ w_resolution=0.5, w_recovery=0.5,
111
+ w_risk=0.7, w_quality=0.3,
112
+ )
113
+
114
+ # Top priority entities
115
+ top_risks = results.nlargest(10, "EWI")
116
+ ```
117
+
63
118
  ## Features
64
119
 
65
120
  - GLMM-based priority matrix (Q1–Q4) with entity-level intercept/slope insights
@@ -22,16 +22,71 @@ import priorityx as px
22
22
 
23
23
  df = pd.read_csv("data.csv")
24
24
 
25
+ # Default: volume x growth (single GLMM)
25
26
  results, stats = px.fit_priority_matrix(
26
27
  df,
27
28
  entity_col="service",
28
29
  timestamp_col="date",
29
30
  temporal_granularity="quarterly",
30
31
  )
32
+ # Returns: entity, x_score, y_score, count, quadrant
31
33
 
32
34
  px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
33
35
  ```
34
36
 
37
+ ### Custom Axes
38
+
39
+ ```python
40
+ # Custom Y axis: volume × resolution_days (two GLMMs)
41
+ results, _ = px.fit_priority_matrix(
42
+ df,
43
+ entity_col="service",
44
+ timestamp_col="date",
45
+ y_metric="resolution_days",
46
+ )
47
+
48
+ # Custom both axes: disputed_amount × paid_amount
49
+ results, _ = px.fit_priority_matrix(
50
+ df,
51
+ entity_col="service",
52
+ timestamp_col="date",
53
+ x_metric="disputed_amount",
54
+ y_metric="paid_amount",
55
+ )
56
+ ```
57
+
58
+ ### Composite Indices
59
+
60
+ ```python
61
+ # Add entity metrics
62
+ metrics = px.aggregate_entity_metrics(
63
+ df,
64
+ entity_col="service",
65
+ duration_start_col="opened_at",
66
+ duration_end_col="closed_at",
67
+ primary_col="exposure",
68
+ secondary_col="recovery",
69
+ )
70
+ results = results.merge(metrics, left_on="entity", right_on="service", how="left")
71
+
72
+ # Add weighted indices: RI (Risk), SQI (Service Quality), EWI (Early Warning)
73
+ results = px.add_priority_indices(
74
+ results,
75
+ volume_col="count",
76
+ growth_col="y_score",
77
+ severity_col="total_primary",
78
+ resolution_col="mean_duration",
79
+ recovery_col="secondary_to_primary_ratio",
80
+ # customize weights (default shown)
81
+ w_volume=0.4, w_growth=0.4, w_severity=0.2,
82
+ w_resolution=0.5, w_recovery=0.5,
83
+ w_risk=0.7, w_quality=0.3,
84
+ )
85
+
86
+ # Top priority entities
87
+ top_risks = results.nlargest(10, "EWI")
88
+ ```
89
+
35
90
  ## Features
36
91
 
37
92
  - GLMM-based priority matrix (Q1–Q4) with entity-level intercept/slope insights
@@ -7,7 +7,7 @@ A four-tier priority system ranks quadrant transitions by urgency using movement
7
7
  | Priority | Label & Color | Main Triggers | Recommended Action |
8
8
  |----------|---------------|---------------|--------------------|
9
9
  | **1 – Crisis** 🔴 | Explosion requiring immediate response | ΔX ≥ 0.40 or ΔY ≥ 0.40 (≈3σ); volume jump ≥ 50 with ≥500 % growth; both axes spiking (`*XY`) | Launch crisis playbook, staff war room, monitor daily |
10
- | **2 – Investigate** 🟠 | Rapid escalation needing urgent review | |ΔX > 0.15 or |ΔY > 0.15; entry into Q1 with strong position; ≥100 % growth with ≥5 new complaints | Trigger early warning, assign analysts, tighten monitoring cadence |
10
+ | **2 – Investigate** 🟠 | Rapid escalation needing urgent review | `|ΔX|` > 0.15 or `|ΔY|` > 0.15; entry into Q1 with strong position; ≥100 % growth with ≥5 new complaints | Trigger early warning, assign analysts, tighten monitoring cadence |
11
11
  | **3 – Monitor** 🟡 | Borderline movement worth watching | Position within ±0.10 of quadrant boundary; gentle Q1 entry | Track trend, document findings, review quarterly |
12
12
  | **4 – Low** 🟢 | Stable or improving | No conditions above met | Maintain routine oversight |
13
13
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "priorityx"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Entity prioritization and escalation detection using GLMM statistical models"
5
5
  authors = [
6
6
  {name = "Okky Mabruri", email = "okkymbrur@gmail.com"}
@@ -8,13 +8,29 @@ users can write::
8
8
 
9
9
  while more advanced workflows can continue to import from the
10
10
  ``core``, ``tracking`` and ``viz`` subpackages directly.
11
+
12
+ ## current version API (consolidated)
13
+
14
+ The unified API uses ``fit_priority_matrix()`` as THE single entry point:
15
+
16
+ # Default: volume x growth
17
+ results, stats = px.fit_priority_matrix(df, entity_col="service", timestamp_col="date")
18
+
19
+ # Custom Y axis: volume x resolution_days
20
+ results, stats = px.fit_priority_matrix(df, ..., y_metric="resolution_days")
21
+
22
+ # Custom both axes: disputed x paid
23
+ results, stats = px.fit_priority_matrix(df, ..., x_metric="disputed", y_metric="paid")
24
+
25
+ Return columns: entity, x_score, y_score, count, quadrant
11
26
  """
12
27
 
13
28
  from .api import ( # noqa: F401
29
+ aggregate_entity_metrics,
30
+ add_priority_indices,
14
31
  display_transition_drivers,
15
32
  extract_transition_drivers,
16
33
  extract_transitions,
17
- fit,
18
34
  fit_priority_matrix,
19
35
  load_or_track_movement,
20
36
  plot_entity_trajectories,
@@ -24,20 +40,25 @@ from .api import ( # noqa: F401
24
40
  track_cumulative_movement,
25
41
  )
26
42
 
27
- __version__ = "0.3.0"
43
+ __version__ = "0.4.0"
28
44
 
29
45
  __all__ = [
30
46
  "__version__",
47
+ # Core - ONE fitting function
31
48
  "fit_priority_matrix",
32
- "fit",
49
+ # Utilities
33
50
  "set_glmm_random_seed",
51
+ # Tracking
34
52
  "track_cumulative_movement",
35
53
  "load_or_track_movement",
36
54
  "extract_transitions",
37
55
  "extract_transition_drivers",
38
56
  "display_transition_drivers",
57
+ # Visualization
39
58
  "plot_priority_matrix",
40
59
  "plot_transition_timeline",
41
60
  "plot_entity_trajectories",
61
+ # Metrics
62
+ "aggregate_entity_metrics",
63
+ "add_priority_indices",
42
64
  ]
43
-
@@ -11,6 +11,7 @@ without losing access to the more detailed submodules under
11
11
  """
12
12
 
13
13
  from .core.glmm import fit_priority_matrix, set_glmm_random_seed
14
+ from .metrics import aggregate_entity_metrics, add_priority_indices, sensitivity_analysis
14
15
  from .tracking.movement import track_cumulative_movement, load_or_track_movement
15
16
  from .tracking.transitions import extract_transitions
16
17
  from .tracking.drivers import (
@@ -22,13 +23,12 @@ from .viz.timeline import plot_transition_timeline
22
23
  from .viz.trajectory import plot_entity_trajectories
23
24
 
24
25
 
25
- # Thin alias for the common GLMM fit path.
26
- fit = fit_priority_matrix
27
-
28
-
26
+ # Public facade exports - current version API (consolidated)
27
+ # Removed: fit(), fit_axes(), fit_priority_axes() - use fit_priority_matrix() with x_metric/y_metric
29
28
  __all__ = [
29
+ # Core GLMM entrypoint - THE single fitting function
30
30
  "fit_priority_matrix",
31
- "fit",
31
+ # Tracking and visualization helpers
32
32
  "set_glmm_random_seed",
33
33
  "track_cumulative_movement",
34
34
  "load_or_track_movement",
@@ -38,4 +38,8 @@ __all__ = [
38
38
  "plot_priority_matrix",
39
39
  "plot_transition_timeline",
40
40
  "plot_entity_trajectories",
41
+ # Metrics
42
+ "aggregate_entity_metrics",
43
+ "add_priority_indices",
44
+ "sensitivity_analysis",
41
45
  ]