priorityx 0.2.6__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.
- {priorityx-0.2.6 → priorityx-0.4.0}/PKG-INFO +59 -13
- priorityx-0.4.0/README.md +107 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/api-reference.md +14 -14
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/priority_classification.md +1 -1
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/quickstart.md +18 -14
- {priorityx-0.2.6 → priorityx-0.4.0}/examples/bugs/bugs_monitoring.py +3 -4
- {priorityx-0.2.6 → priorityx-0.4.0}/examples/incidents/incident_monitoring.py +9 -18
- {priorityx-0.2.6 → priorityx-0.4.0}/examples/violations/violations_monitoring.py +6 -10
- {priorityx-0.2.6 → priorityx-0.4.0}/pyproject.toml +1 -1
- priorityx-0.4.0/src/priorityx/__init__.py +64 -0
- priorityx-0.4.0/src/priorityx/api.py +45 -0
- priorityx-0.4.0/src/priorityx/core/glmm.py +758 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/core/quadrants.py +11 -10
- priorityx-0.4.0/src/priorityx/metrics.py +397 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/tracking/drivers.py +8 -5
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/tracking/movement.py +17 -5
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/tracking/transitions.py +14 -15
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/viz/matrix.py +169 -53
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/viz/timeline.py +40 -6
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/viz/trajectory.py +24 -18
- priorityx-0.4.0/tests/test_api_axes.py +90 -0
- priorityx-0.4.0/tests/test_glmm.py +252 -0
- priorityx-0.4.0/tests/test_metrics.py +78 -0
- priorityx-0.4.0/tests/test_movement_monthly.py +105 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/tests/test_quadrants.py +4 -2
- {priorityx-0.2.6 → priorityx-0.4.0}/tests/test_transitions.py +21 -0
- priorityx-0.4.0/tests/test_viz_matrix.py +47 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/uv.lock +82 -92
- priorityx-0.2.6/README.md +0 -61
- priorityx-0.2.6/src/priorityx/__init__.py +0 -7
- priorityx-0.2.6/src/priorityx/core/glmm.py +0 -429
- priorityx-0.2.6/tests/test_glmm.py +0 -142
- {priorityx-0.2.6 → priorityx-0.4.0}/.github/workflows/release.yml +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/.github/workflows/test.yml +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/.gitignore +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/LICENSE +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/Makefile +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/README.md +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/methodology.md +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/docs/output_naming.md +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/examples/README.md +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/scripts/version.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/core/__init__.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/core/filters.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/tracking/__init__.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/utils/__init__.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/utils/helpers.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/src/priorityx/viz/__init__.py +0 -0
- {priorityx-0.2.6 → priorityx-0.4.0}/tests/test_drivers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: priorityx
|
|
3
|
-
Version: 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
|
|
@@ -44,29 +44,75 @@ pip install priorityx
|
|
|
44
44
|
|
|
45
45
|
## Quick Start
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
```python
|
|
48
|
+
import pandas as pd
|
|
49
|
+
import priorityx as px
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
df = pd.read_csv("data.csv")
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
# Default: volume x growth (single GLMM)
|
|
54
|
+
results, stats = px.fit_priority_matrix(
|
|
55
|
+
df,
|
|
56
|
+
entity_col="service",
|
|
57
|
+
timestamp_col="date",
|
|
58
|
+
temporal_granularity="quarterly",
|
|
59
|
+
)
|
|
60
|
+
# Returns: entity, x_score, y_score, count, quadrant
|
|
61
|
+
|
|
62
|
+
px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
|
|
53
63
|
```
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
import pandas as pd
|
|
57
|
-
from priorityx.core.glmm import fit_priority_matrix
|
|
58
|
-
from priorityx.viz.matrix import plot_priority_matrix
|
|
65
|
+
### Custom Axes
|
|
59
66
|
|
|
60
|
-
|
|
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
|
+
)
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
# Custom both axes: disputed_amount × paid_amount
|
|
77
|
+
results, _ = px.fit_priority_matrix(
|
|
63
78
|
df,
|
|
64
79
|
entity_col="service",
|
|
65
80
|
timestamp_col="date",
|
|
66
|
-
|
|
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,
|
|
67
112
|
)
|
|
68
113
|
|
|
69
|
-
|
|
114
|
+
# Top priority entities
|
|
115
|
+
top_risks = results.nlargest(10, "EWI")
|
|
70
116
|
```
|
|
71
117
|
|
|
72
118
|
## Features
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Priorityx: Entity prioritization and escalation detection using GLMM statistical models
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/priorityx)
|
|
4
|
+
[](https://pepy.tech/project/priorityx)
|
|
5
|
+
[](https://github.com/okkymabruri/priorityx/actions)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
Entity prioritization and escalation detection using GLMM statistical models
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install priorityx
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import pandas as pd
|
|
21
|
+
import priorityx as px
|
|
22
|
+
|
|
23
|
+
df = pd.read_csv("data.csv")
|
|
24
|
+
|
|
25
|
+
# Default: volume x growth (single GLMM)
|
|
26
|
+
results, stats = px.fit_priority_matrix(
|
|
27
|
+
df,
|
|
28
|
+
entity_col="service",
|
|
29
|
+
timestamp_col="date",
|
|
30
|
+
temporal_granularity="quarterly",
|
|
31
|
+
)
|
|
32
|
+
# Returns: entity, x_score, y_score, count, quadrant
|
|
33
|
+
|
|
34
|
+
px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
|
|
35
|
+
```
|
|
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
|
+
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
- GLMM-based priority matrix (Q1–Q4) with entity-level intercept/slope insights
|
|
93
|
+
- Priority-based transition timeline (Crisis / Investigate / Monitor / Low) with spike markers (`*X`, `*Y`, `*XY`)
|
|
94
|
+
- Cumulative movement tracking and trajectory visualizations
|
|
95
|
+
- Transition driver analysis that surfaces top subcategories causing quadrant shifts with spike summaries
|
|
96
|
+
- Deterministic seeding option for reproducible GLMM runs (set `PRIORITYX_GLMM_SEED`)
|
|
97
|
+
|
|
98
|
+
## Use Cases
|
|
99
|
+
|
|
100
|
+
IT incidents, software bugs, compliance violations, performance monitoring.
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
- [Quick Start](docs/quickstart.md)
|
|
105
|
+
- [API Reference](docs/api-reference.md)
|
|
106
|
+
- [Methodology](docs/methodology.md)
|
|
107
|
+
- [Priority Classification](docs/priority_classification.md)
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
### fit_priority_matrix
|
|
6
6
|
|
|
7
7
|
```python
|
|
8
|
-
|
|
8
|
+
import priorityx as px
|
|
9
9
|
|
|
10
|
-
results, stats = fit_priority_matrix(
|
|
10
|
+
results, stats = px.fit_priority_matrix(
|
|
11
11
|
df,
|
|
12
12
|
entity_col,
|
|
13
13
|
timestamp_col,
|
|
@@ -50,9 +50,9 @@ Fits Poisson GLMM to classify entities into priority quadrants.
|
|
|
50
50
|
### track_cumulative_movement
|
|
51
51
|
|
|
52
52
|
```python
|
|
53
|
-
|
|
53
|
+
import priorityx as px
|
|
54
54
|
|
|
55
|
-
movement, meta = track_cumulative_movement(
|
|
55
|
+
movement, meta = px.track_cumulative_movement(
|
|
56
56
|
df,
|
|
57
57
|
entity_col,
|
|
58
58
|
timestamp_col,
|
|
@@ -74,9 +74,9 @@ Tracks entity movement through priority quadrants over time.
|
|
|
74
74
|
### extract_transitions
|
|
75
75
|
|
|
76
76
|
```python
|
|
77
|
-
|
|
77
|
+
import priorityx as px
|
|
78
78
|
|
|
79
|
-
transitions = extract_transitions(
|
|
79
|
+
transitions = px.extract_transitions(
|
|
80
80
|
movement_df,
|
|
81
81
|
focus_risk_increasing=True
|
|
82
82
|
)
|
|
@@ -90,9 +90,9 @@ Extracts quadrant transitions from movement data.
|
|
|
90
90
|
### extract_transition_drivers
|
|
91
91
|
|
|
92
92
|
```python
|
|
93
|
-
|
|
93
|
+
import priorityx as px
|
|
94
94
|
|
|
95
|
-
analysis = extract_transition_drivers(
|
|
95
|
+
analysis = px.extract_transition_drivers(
|
|
96
96
|
movement_df,
|
|
97
97
|
df_raw,
|
|
98
98
|
entity_name="Service A",
|
|
@@ -156,9 +156,9 @@ Classifies supervisory priority (1=Critical, 2=Investigate, 3=Monitor, 4=Low).
|
|
|
156
156
|
### plot_priority_matrix
|
|
157
157
|
|
|
158
158
|
```python
|
|
159
|
-
|
|
159
|
+
import priorityx as px
|
|
160
160
|
|
|
161
|
-
fig = plot_priority_matrix(
|
|
161
|
+
fig = px.plot_priority_matrix(
|
|
162
162
|
results_df,
|
|
163
163
|
entity_name="Entity",
|
|
164
164
|
figsize=(16, 12),
|
|
@@ -174,9 +174,9 @@ Creates scatter plot of priority matrix.
|
|
|
174
174
|
### plot_transition_timeline
|
|
175
175
|
|
|
176
176
|
```python
|
|
177
|
-
|
|
177
|
+
import priorityx as px
|
|
178
178
|
|
|
179
|
-
fig = plot_transition_timeline(
|
|
179
|
+
fig = px.plot_transition_timeline(
|
|
180
180
|
transitions_df,
|
|
181
181
|
entity_name="Entity",
|
|
182
182
|
filter_risk_levels=["critical", "high"],
|
|
@@ -192,9 +192,9 @@ Creates timeline heatmap of transitions. Passing `movement_df` is required to co
|
|
|
192
192
|
### plot_entity_trajectories
|
|
193
193
|
|
|
194
194
|
```python
|
|
195
|
-
|
|
195
|
+
import priorityx as px
|
|
196
196
|
|
|
197
|
-
fig = plot_entity_trajectories(
|
|
197
|
+
fig = px.plot_entity_trajectories(
|
|
198
198
|
movement_df,
|
|
199
199
|
entity_name="Entity",
|
|
200
200
|
max_entities=10,
|
|
@@ -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 |
|
|
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
|
|
|
@@ -10,36 +10,32 @@ pip install priorityx
|
|
|
10
10
|
|
|
11
11
|
```python
|
|
12
12
|
import pandas as pd
|
|
13
|
-
|
|
14
|
-
from priorityx.viz.matrix import plot_priority_matrix
|
|
13
|
+
import priorityx as px
|
|
15
14
|
|
|
16
15
|
# load your data
|
|
17
16
|
df = pd.read_csv("your_data.csv")
|
|
18
17
|
df["date"] = pd.to_datetime(df["date"])
|
|
19
18
|
|
|
20
19
|
# fit priority matrix
|
|
21
|
-
results, stats = fit_priority_matrix(
|
|
20
|
+
results, stats = px.fit_priority_matrix(
|
|
22
21
|
df,
|
|
23
22
|
entity_col="service", # your entity column
|
|
24
23
|
timestamp_col="date", # your date column
|
|
25
24
|
temporal_granularity="quarterly",
|
|
26
|
-
min_observations=8
|
|
25
|
+
min_observations=8,
|
|
27
26
|
)
|
|
28
27
|
|
|
29
28
|
# visualize
|
|
30
|
-
plot_priority_matrix(results, entity_name="Service", save_plot=True)
|
|
29
|
+
px.plot_priority_matrix(results, entity_name="Service", save_plot=True)
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
## Full Workflow
|
|
34
33
|
|
|
35
34
|
```python
|
|
36
|
-
|
|
37
|
-
from priorityx.tracking.transitions import extract_transitions
|
|
38
|
-
from priorityx.tracking.drivers import extract_transition_drivers, display_transition_drivers
|
|
39
|
-
from priorityx.viz.timeline import plot_transition_timeline
|
|
35
|
+
import priorityx as px
|
|
40
36
|
|
|
41
37
|
# track movement over time
|
|
42
|
-
movement, meta = track_cumulative_movement(
|
|
38
|
+
movement, meta = px.track_cumulative_movement(
|
|
43
39
|
df,
|
|
44
40
|
entity_col="service",
|
|
45
41
|
timestamp_col="date",
|
|
@@ -47,15 +43,15 @@ movement, meta = track_cumulative_movement(
|
|
|
47
43
|
)
|
|
48
44
|
|
|
49
45
|
# detect transitions
|
|
50
|
-
transitions = extract_transitions(movement)
|
|
46
|
+
transitions = px.extract_transitions(movement)
|
|
51
47
|
|
|
52
48
|
# visualize transitions
|
|
53
|
-
plot_transition_timeline(transitions, entity_name="Service", save_plot=True)
|
|
49
|
+
px.plot_transition_timeline(transitions, entity_name="Service", save_plot=True)
|
|
54
50
|
|
|
55
51
|
# analyze drivers for specific transition
|
|
56
52
|
if not transitions.empty:
|
|
57
53
|
first_transition = transitions.iloc[0]
|
|
58
|
-
analysis = extract_transition_drivers(
|
|
54
|
+
analysis = px.extract_transition_drivers(
|
|
59
55
|
movement_df=movement,
|
|
60
56
|
df_raw=df,
|
|
61
57
|
entity_name=first_transition["entity"],
|
|
@@ -66,7 +62,7 @@ if not transitions.empty:
|
|
|
66
62
|
top_n_subcategories=5,
|
|
67
63
|
min_subcategory_delta=2
|
|
68
64
|
)
|
|
69
|
-
display_transition_drivers(analysis)
|
|
65
|
+
px.display_transition_drivers(analysis)
|
|
70
66
|
|
|
71
67
|
# subcategory columns (e.g., severity/product/topic) are auto-detected
|
|
72
68
|
# when not provided; pass subcategory_cols=[...] to override.
|
|
@@ -86,3 +82,11 @@ By default, outputs saved to:
|
|
|
86
82
|
- **`results/`** - All CSV data files (entity scores, transitions, movement tracking)
|
|
87
83
|
|
|
88
84
|
You can customize output directories using the `output_dir` parameter in visualization functions.
|
|
85
|
+
|
|
86
|
+
## Deterministic runs
|
|
87
|
+
|
|
88
|
+
Set `PRIORITYX_GLMM_SEED` (or call `set_glmm_random_seed()`) before running analyses to obtain repeatable GLMM estimates during debugging or CI checks:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
PRIORITYX_GLMM_SEED=1234 python your_script.py
|
|
92
|
+
```
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
# software bug tracking example (data pulled from GitHub raw)
|
|
3
3
|
import pandas as pd
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
from priorityx.viz.matrix import plot_priority_matrix
|
|
5
|
+
import priorityx as px
|
|
7
6
|
|
|
8
7
|
RAW_DATA_URL = "https://raw.githubusercontent.com/okkymabruri/priorityx/main/examples/bugs/bugs.csv"
|
|
9
8
|
|
|
@@ -15,7 +14,7 @@ df["date"] = df["reported_date"]
|
|
|
15
14
|
temporal_granularity = "quarterly"
|
|
16
15
|
entity_name = "Component"
|
|
17
16
|
|
|
18
|
-
results, stats = fit_priority_matrix(
|
|
17
|
+
results, stats = px.fit_priority_matrix(
|
|
19
18
|
df,
|
|
20
19
|
entity_col="component",
|
|
21
20
|
timestamp_col="date",
|
|
@@ -28,7 +27,7 @@ print("Software Bug Priority Matrix:")
|
|
|
28
27
|
print(results[["entity", "Random_Intercept", "Random_Slope", "count", "quadrant"]])
|
|
29
28
|
|
|
30
29
|
# visualize
|
|
31
|
-
plot_priority_matrix(
|
|
30
|
+
px.plot_priority_matrix(
|
|
32
31
|
results,
|
|
33
32
|
entity_name=entity_name,
|
|
34
33
|
show_quadrant_labels=True,
|
|
@@ -3,16 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
from priorityx.tracking.movement import track_cumulative_movement
|
|
8
|
-
from priorityx.tracking.transitions import extract_transitions
|
|
9
|
-
from priorityx.tracking.drivers import (
|
|
10
|
-
extract_transition_drivers,
|
|
11
|
-
display_transition_drivers,
|
|
12
|
-
)
|
|
13
|
-
from priorityx.viz.matrix import plot_priority_matrix
|
|
14
|
-
from priorityx.viz.timeline import plot_transition_timeline
|
|
15
|
-
from priorityx.viz.trajectory import plot_entity_trajectories
|
|
6
|
+
import priorityx as px
|
|
16
7
|
from priorityx.utils.helpers import (
|
|
17
8
|
display_quadrant_summary,
|
|
18
9
|
display_transition_summary,
|
|
@@ -34,7 +25,7 @@ print("PRIORITY MATRIX ANALYSIS")
|
|
|
34
25
|
|
|
35
26
|
temporal_granularity = "quarterly"
|
|
36
27
|
entity_name = "Service"
|
|
37
|
-
results, stats = fit_priority_matrix(
|
|
28
|
+
results, stats = px.fit_priority_matrix(
|
|
38
29
|
df,
|
|
39
30
|
entity_col="service",
|
|
40
31
|
timestamp_col="date",
|
|
@@ -49,7 +40,7 @@ print(results[["entity", "Random_Intercept", "Random_Slope", "count", "quadrant"
|
|
|
49
40
|
display_quadrant_summary(results, entity_name=entity_name, min_count=0)
|
|
50
41
|
|
|
51
42
|
# visualize
|
|
52
|
-
plot_priority_matrix(
|
|
43
|
+
px.plot_priority_matrix(
|
|
53
44
|
results,
|
|
54
45
|
entity_name=entity_name,
|
|
55
46
|
show_quadrant_labels=True,
|
|
@@ -61,7 +52,7 @@ plot_priority_matrix(
|
|
|
61
52
|
print()
|
|
62
53
|
print("CUMULATIVE MOVEMENT TRACKING")
|
|
63
54
|
|
|
64
|
-
movement, meta = track_cumulative_movement(
|
|
55
|
+
movement, meta = px.track_cumulative_movement(
|
|
65
56
|
df,
|
|
66
57
|
entity_col="service",
|
|
67
58
|
timestamp_col="date",
|
|
@@ -84,7 +75,7 @@ movement_path = save_dataframe_to_csv(
|
|
|
84
75
|
print(f"Movement CSV saved: {movement_path}")
|
|
85
76
|
|
|
86
77
|
# visualize entity trajectories
|
|
87
|
-
plot_entity_trajectories(
|
|
78
|
+
px.plot_entity_trajectories(
|
|
88
79
|
movement,
|
|
89
80
|
entity_name=entity_name,
|
|
90
81
|
max_entities=5,
|
|
@@ -93,12 +84,12 @@ plot_entity_trajectories(
|
|
|
93
84
|
)
|
|
94
85
|
|
|
95
86
|
# detect transitions
|
|
96
|
-
transitions = extract_transitions(movement, focus_risk_increasing=True)
|
|
87
|
+
transitions = px.extract_transitions(movement, focus_risk_increasing=True)
|
|
97
88
|
|
|
98
89
|
print(f"\nDetected {len(transitions)} risk-increasing transitions")
|
|
99
90
|
display_transition_summary(transitions, entity_name=entity_name)
|
|
100
91
|
|
|
101
|
-
plot_transition_timeline(
|
|
92
|
+
px.plot_transition_timeline(
|
|
102
93
|
transitions,
|
|
103
94
|
entity_name=entity_name,
|
|
104
95
|
save_plot=True,
|
|
@@ -129,7 +120,7 @@ if len(critical_transitions) > 0:
|
|
|
129
120
|
)
|
|
130
121
|
|
|
131
122
|
if prev_quarter:
|
|
132
|
-
driver_analysis = extract_transition_drivers(
|
|
123
|
+
driver_analysis = px.extract_transition_drivers(
|
|
133
124
|
movement_df=movement,
|
|
134
125
|
df_raw=df,
|
|
135
126
|
entity_name=trans["entity"],
|
|
@@ -141,7 +132,7 @@ if len(critical_transitions) > 0:
|
|
|
141
132
|
min_subcategory_delta=2,
|
|
142
133
|
)
|
|
143
134
|
|
|
144
|
-
display_transition_drivers(driver_analysis)
|
|
135
|
+
px.display_transition_drivers(driver_analysis)
|
|
145
136
|
|
|
146
137
|
print()
|
|
147
138
|
print("Analysis complete. Check plot/ and results/ in the current working directory.")
|
|
@@ -4,11 +4,7 @@ from datetime import datetime, timedelta
|
|
|
4
4
|
|
|
5
5
|
import pandas as pd
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
from priorityx.tracking.movement import track_cumulative_movement
|
|
9
|
-
from priorityx.tracking.transitions import extract_transitions
|
|
10
|
-
from priorityx.viz.matrix import plot_priority_matrix
|
|
11
|
-
from priorityx.viz.timeline import plot_transition_timeline
|
|
7
|
+
import priorityx as px
|
|
12
8
|
from priorityx.utils.helpers import (
|
|
13
9
|
display_quadrant_summary,
|
|
14
10
|
display_transition_summary,
|
|
@@ -64,7 +60,7 @@ df = pd.DataFrame(data)
|
|
|
64
60
|
temporal_granularity = "quarterly"
|
|
65
61
|
entity_name = "Department"
|
|
66
62
|
|
|
67
|
-
results, stats = fit_priority_matrix(
|
|
63
|
+
results, stats = px.fit_priority_matrix(
|
|
68
64
|
df,
|
|
69
65
|
entity_col="department",
|
|
70
66
|
timestamp_col="date",
|
|
@@ -76,7 +72,7 @@ print(results[["entity", "Random_Intercept", "Random_Slope", "count", "quadrant"
|
|
|
76
72
|
|
|
77
73
|
display_quadrant_summary(results, entity_name=entity_name, min_count=0)
|
|
78
74
|
|
|
79
|
-
plot_priority_matrix(
|
|
75
|
+
px.plot_priority_matrix(
|
|
80
76
|
results,
|
|
81
77
|
entity_name=entity_name,
|
|
82
78
|
show_quadrant_labels=True,
|
|
@@ -84,7 +80,7 @@ plot_priority_matrix(
|
|
|
84
80
|
save_csv=True,
|
|
85
81
|
)
|
|
86
82
|
|
|
87
|
-
movement, meta = track_cumulative_movement(
|
|
83
|
+
movement, meta = px.track_cumulative_movement(
|
|
88
84
|
df,
|
|
89
85
|
entity_col="department",
|
|
90
86
|
timestamp_col="date",
|
|
@@ -100,12 +96,12 @@ movement_path = save_dataframe_to_csv(
|
|
|
100
96
|
temporal_granularity=temporal_granularity,
|
|
101
97
|
)
|
|
102
98
|
print(f"Movement CSV saved: {movement_path}")
|
|
103
|
-
transitions = extract_transitions(movement, focus_risk_increasing=True)
|
|
99
|
+
transitions = px.extract_transitions(movement, focus_risk_increasing=True)
|
|
104
100
|
|
|
105
101
|
print(f"\nDetected {len(transitions)} risk-increasing transitions")
|
|
106
102
|
display_transition_summary(transitions, entity_name=entity_name)
|
|
107
103
|
|
|
108
|
-
plot_transition_timeline(
|
|
104
|
+
px.plot_transition_timeline(
|
|
109
105
|
transitions,
|
|
110
106
|
entity_name=entity_name,
|
|
111
107
|
save_plot=True,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""priorityx: Entity prioritization and escalation detection using GLMM statistical models.
|
|
2
|
+
|
|
3
|
+
The :mod:`priorityx.api` module exposes a small convenience facade so
|
|
4
|
+
users can write::
|
|
5
|
+
|
|
6
|
+
import priorityx as px
|
|
7
|
+
results, stats = px.fit_priority_matrix(...)
|
|
8
|
+
|
|
9
|
+
while more advanced workflows can continue to import from the
|
|
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
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from .api import ( # noqa: F401
|
|
29
|
+
aggregate_entity_metrics,
|
|
30
|
+
add_priority_indices,
|
|
31
|
+
display_transition_drivers,
|
|
32
|
+
extract_transition_drivers,
|
|
33
|
+
extract_transitions,
|
|
34
|
+
fit_priority_matrix,
|
|
35
|
+
load_or_track_movement,
|
|
36
|
+
plot_entity_trajectories,
|
|
37
|
+
plot_priority_matrix,
|
|
38
|
+
plot_transition_timeline,
|
|
39
|
+
set_glmm_random_seed,
|
|
40
|
+
track_cumulative_movement,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
__version__ = "0.4.0"
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"__version__",
|
|
47
|
+
# Core - ONE fitting function
|
|
48
|
+
"fit_priority_matrix",
|
|
49
|
+
# Utilities
|
|
50
|
+
"set_glmm_random_seed",
|
|
51
|
+
# Tracking
|
|
52
|
+
"track_cumulative_movement",
|
|
53
|
+
"load_or_track_movement",
|
|
54
|
+
"extract_transitions",
|
|
55
|
+
"extract_transition_drivers",
|
|
56
|
+
"display_transition_drivers",
|
|
57
|
+
# Visualization
|
|
58
|
+
"plot_priority_matrix",
|
|
59
|
+
"plot_transition_timeline",
|
|
60
|
+
"plot_entity_trajectories",
|
|
61
|
+
# Metrics
|
|
62
|
+
"aggregate_entity_metrics",
|
|
63
|
+
"add_priority_indices",
|
|
64
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Public convenience API for PriorityX.
|
|
2
|
+
|
|
3
|
+
This module exposes the most commonly used functions via a compact
|
|
4
|
+
namespace so users can write:
|
|
5
|
+
|
|
6
|
+
import priorityx as px
|
|
7
|
+
results, stats = px.fit_priority_matrix(...)
|
|
8
|
+
|
|
9
|
+
without losing access to the more detailed submodules under
|
|
10
|
+
``priorityx.core``, ``priorityx.tracking``, or ``priorityx.viz``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .core.glmm import fit_priority_matrix, set_glmm_random_seed
|
|
14
|
+
from .metrics import aggregate_entity_metrics, add_priority_indices, sensitivity_analysis
|
|
15
|
+
from .tracking.movement import track_cumulative_movement, load_or_track_movement
|
|
16
|
+
from .tracking.transitions import extract_transitions
|
|
17
|
+
from .tracking.drivers import (
|
|
18
|
+
extract_transition_drivers,
|
|
19
|
+
display_transition_drivers,
|
|
20
|
+
)
|
|
21
|
+
from .viz.matrix import plot_priority_matrix
|
|
22
|
+
from .viz.timeline import plot_transition_timeline
|
|
23
|
+
from .viz.trajectory import plot_entity_trajectories
|
|
24
|
+
|
|
25
|
+
|
|
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
|
|
28
|
+
__all__ = [
|
|
29
|
+
# Core GLMM entrypoint - THE single fitting function
|
|
30
|
+
"fit_priority_matrix",
|
|
31
|
+
# Tracking and visualization helpers
|
|
32
|
+
"set_glmm_random_seed",
|
|
33
|
+
"track_cumulative_movement",
|
|
34
|
+
"load_or_track_movement",
|
|
35
|
+
"extract_transitions",
|
|
36
|
+
"extract_transition_drivers",
|
|
37
|
+
"display_transition_drivers",
|
|
38
|
+
"plot_priority_matrix",
|
|
39
|
+
"plot_transition_timeline",
|
|
40
|
+
"plot_entity_trajectories",
|
|
41
|
+
# Metrics
|
|
42
|
+
"aggregate_entity_metrics",
|
|
43
|
+
"add_priority_indices",
|
|
44
|
+
"sensitivity_analysis",
|
|
45
|
+
]
|