priorityx 0.1.1__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.
@@ -0,0 +1,97 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build:
13
+ name: Build package
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v6
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Verify version matches tag
24
+ if: startsWith(github.ref, 'refs/tags/')
25
+ run: |
26
+ TAG_VERSION=${GITHUB_REF#refs/tags/v}
27
+ FILE_VERSION=$(grep -Pom1 '^\s*version\s*=\s*"\K[^"]+' pyproject.toml)
28
+ if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then
29
+ echo "Version mismatch!"
30
+ echo " Tag: v$TAG_VERSION"
31
+ echo " File: $FILE_VERSION"
32
+ exit 1
33
+ fi
34
+ echo "Version check passed: $FILE_VERSION"
35
+
36
+ - name: Install uv
37
+ uses: astral-sh/setup-uv@v4
38
+
39
+ - name: Build distributions
40
+ run: |
41
+ uv build
42
+ ls -lah dist/
43
+
44
+ - name: Upload artifacts
45
+ uses: actions/upload-artifact@v5
46
+ with:
47
+ name: python-package-distributions
48
+ path: dist/
49
+ retention-days: 1
50
+ if-no-files-found: error
51
+
52
+ publish-pypi:
53
+ name: Publish to PyPI
54
+ needs: [build]
55
+ runs-on: ubuntu-latest
56
+ if: |
57
+ github.event_name == 'push' &&
58
+ startsWith(github.ref, 'refs/tags/v')
59
+
60
+ environment:
61
+ name: pypi
62
+ url: https://pypi.org/p/priorityx
63
+
64
+ permissions:
65
+ id-token: write
66
+
67
+ steps:
68
+ - name: Download distributions
69
+ uses: actions/download-artifact@v5
70
+ with:
71
+ name: python-package-distributions
72
+ path: dist/
73
+
74
+ - name: Publish to PyPI
75
+ uses: pypa/gh-action-pypi-publish@release/v1
76
+ with:
77
+ verbose: true
78
+ print-hash: true
79
+ skip-existing: true
80
+ attestations: true
81
+
82
+ create-release:
83
+ name: Create GitHub Release
84
+ needs: [publish-pypi]
85
+ runs-on: ubuntu-latest
86
+ permissions:
87
+ contents: write
88
+
89
+ steps:
90
+ - uses: actions/checkout@v5
91
+
92
+ - name: Create Release
93
+ uses: softprops/action-gh-release@v2
94
+ with:
95
+ generate_release_notes: true
96
+ draft: false
97
+ prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') }}
@@ -0,0 +1,32 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.10', '3.11', '3.12']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+
19
+ - uses: actions/setup-python@v6
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install uv
24
+ run: pip install uv
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ uv sync
29
+ uv pip install -e .
30
+
31
+ - name: Run tests
32
+ run: uv run pytest tests/
@@ -0,0 +1,213 @@
1
+ # Custom
2
+ dev/
3
+ tmp/
4
+ *.csv
5
+ *.png
6
+
7
+ # Byte-compiled / optimized / DLL files
8
+ __pycache__/
9
+ *.py[codz]
10
+ *$py.class
11
+
12
+ # C extensions
13
+ *.so
14
+
15
+ # Distribution / packaging
16
+ .Python
17
+ build/
18
+ develop-eggs/
19
+ dist/
20
+ downloads/
21
+ eggs/
22
+ .eggs/
23
+ lib/
24
+ lib64/
25
+ parts/
26
+ sdist/
27
+ var/
28
+ wheels/
29
+ share/python-wheels/
30
+ *.egg-info/
31
+ .installed.cfg
32
+ *.egg
33
+ MANIFEST
34
+
35
+ # PyInstaller
36
+ # Usually these files are written by a python script from a template
37
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
38
+ *.manifest
39
+ *.spec
40
+
41
+ # Installer logs
42
+ pip-log.txt
43
+ pip-delete-this-directory.txt
44
+
45
+ # Unit test / coverage reports
46
+ htmlcov/
47
+ .tox/
48
+ .nox/
49
+ .coverage
50
+ .coverage.*
51
+ .cache
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ *.py.cover
56
+ .hypothesis/
57
+ .pytest_cache/
58
+ cover/
59
+
60
+ # Translations
61
+ *.mo
62
+ *.pot
63
+
64
+ # Django stuff:
65
+ *.log
66
+ local_settings.py
67
+ db.sqlite3
68
+ db.sqlite3-journal
69
+
70
+ # Flask stuff:
71
+ instance/
72
+ .webassets-cache
73
+
74
+ # Scrapy stuff:
75
+ .scrapy
76
+
77
+ # Sphinx documentation
78
+ docs/_build/
79
+
80
+ # PyBuilder
81
+ .pybuilder/
82
+ target/
83
+
84
+ # Jupyter Notebook
85
+ .ipynb_checkpoints
86
+
87
+ # IPython
88
+ profile_default/
89
+ ipython_config.py
90
+
91
+ # pyenv
92
+ # For a library or package, you might want to ignore these files since the code is
93
+ # intended to run in multiple environments; otherwise, check them in:
94
+ # .python-version
95
+
96
+ # pipenv
97
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
98
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
99
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
100
+ # install all needed dependencies.
101
+ #Pipfile.lock
102
+
103
+ # UV
104
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ #uv.lock
108
+
109
+ # poetry
110
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
111
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
112
+ # commonly ignored for libraries.
113
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
114
+ #poetry.lock
115
+ #poetry.toml
116
+
117
+ # pdm
118
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
119
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
120
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
121
+ #pdm.lock
122
+ #pdm.toml
123
+ .pdm-python
124
+ .pdm-build/
125
+
126
+ # pixi
127
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
128
+ #pixi.lock
129
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
130
+ # in the .venv directory. It is recommended not to include this directory in version control.
131
+ .pixi
132
+
133
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
134
+ __pypackages__/
135
+
136
+ # Celery stuff
137
+ celerybeat-schedule
138
+ celerybeat.pid
139
+
140
+ # SageMath parsed files
141
+ *.sage.py
142
+
143
+ # Environments
144
+ .env
145
+ .envrc
146
+ .venv
147
+ env/
148
+ venv/
149
+ ENV/
150
+ env.bak/
151
+ venv.bak/
152
+
153
+ # Spyder project settings
154
+ .spyderproject
155
+ .spyproject
156
+
157
+ # Rope project settings
158
+ .ropeproject
159
+
160
+ # mkdocs documentation
161
+ /site
162
+
163
+ # mypy
164
+ .mypy_cache/
165
+ .dmypy.json
166
+ dmypy.json
167
+
168
+ # Pyre type checker
169
+ .pyre/
170
+
171
+ # pytype static type analyzer
172
+ .pytype/
173
+
174
+ # Cython debug symbols
175
+ cython_debug/
176
+
177
+ # PyCharm
178
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
179
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
180
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
181
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
182
+ #.idea/
183
+
184
+ # Abstra
185
+ # Abstra is an AI-powered process automation framework.
186
+ # Ignore directories containing user credentials, local state, and settings.
187
+ # Learn more at https://abstra.io/docs
188
+ .abstra/
189
+
190
+ # Visual Studio Code
191
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
192
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
193
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
194
+ # you could uncomment the following to ignore the entire vscode folder
195
+ # .vscode/
196
+
197
+ # Ruff stuff:
198
+ .ruff_cache/
199
+
200
+ # PyPI configuration file
201
+ .pypirc
202
+
203
+ # Cursor
204
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
205
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
206
+ # refer to https://docs.cursor.com/context/ignore-files
207
+ .cursorignore
208
+ .cursorindexingignore
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Okky Mabruri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # Version management for priorityx
2
+
3
+ .PHONY: release release-patch release-minor release-major test
4
+
5
+ # Release patch version
6
+ release-patch:
7
+ @uv run python scripts/version.py release
8
+
9
+ # Release minor version
10
+ release-minor:
11
+ @uv run python scripts/version.py release --minor
12
+
13
+ # Release major version
14
+ release-major:
15
+ @uv run python scripts/version.py release --major
16
+
17
+ # Release specific version (e.g., make release VERSION=0.2.0)
18
+ release:
19
+ @test -n "$(VERSION)" || (echo "Error: Set VERSION=x.y.z" && exit 1)
20
+ @uv run python scripts/version.py release $(VERSION)
21
+
22
+ # Run tests
23
+ test:
24
+ @uv run pytest tests/
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: priorityx
3
+ Version: 0.1.1
4
+ Summary: Entity prioritization and escalation detection using GLMM statistical models
5
+ Project-URL: Homepage, https://github.com/okkymabruri/priorityx
6
+ Project-URL: Repository, https://github.com/okkymabruri/priorityx
7
+ Project-URL: Issues, https://github.com/okkymabruri/priorityx/issues
8
+ Author-email: Okky Mabruri <okkymbrur@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: escalation-detection,glmm,prioritization,risk-analysis,statistical-modeling
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: adjusttext>=1.3.0
24
+ Requires-Dist: matplotlib>=3.9.4
25
+ Requires-Dist: pandas>=2.3.3
26
+ Requires-Dist: polars>=1.35.1
27
+ Requires-Dist: pyarrow>=21.0.0
28
+ Requires-Dist: statsmodels>=0.14.5
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Priorityx: Entity prioritization and escalation detection using GLMM statistical models
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install priorityx
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ import polars as pl
43
+ from priorityx.core.glmm import fit_priority_matrix
44
+ from priorityx.viz.matrix import plot_priority_matrix
45
+
46
+ df = pl.read_csv("data.csv")
47
+
48
+ results, stats = fit_priority_matrix(
49
+ df,
50
+ entity_col="service",
51
+ timestamp_col="date",
52
+ temporal_granularity="quarterly"
53
+ )
54
+
55
+ plot_priority_matrix(results, entity_name="Service", save_plot=True)
56
+ ```
57
+
58
+ ## Features
59
+
60
+ - GLMM-based priority classification (Q1-Q4 quadrants)
61
+ - Transition detection over time
62
+ - Movement tracking
63
+ - Visualization
64
+
65
+ ## Use Cases
66
+
67
+ IT incidents, software bugs, compliance violations, performance monitoring.
68
+
69
+ ## Documentation
70
+
71
+ - [Quick Start](docs/quickstart.md)
72
+ - [API Reference](docs/api-reference.md)
73
+ - [Methodology](docs/methodology.md)
@@ -0,0 +1,43 @@
1
+ # Priorityx: Entity prioritization and escalation detection using GLMM statistical models
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ pip install priorityx
7
+ ```
8
+
9
+ ## Quick Start
10
+
11
+ ```python
12
+ import polars as pl
13
+ from priorityx.core.glmm import fit_priority_matrix
14
+ from priorityx.viz.matrix import plot_priority_matrix
15
+
16
+ df = pl.read_csv("data.csv")
17
+
18
+ results, stats = fit_priority_matrix(
19
+ df,
20
+ entity_col="service",
21
+ timestamp_col="date",
22
+ temporal_granularity="quarterly"
23
+ )
24
+
25
+ plot_priority_matrix(results, entity_name="Service", save_plot=True)
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - GLMM-based priority classification (Q1-Q4 quadrants)
31
+ - Transition detection over time
32
+ - Movement tracking
33
+ - Visualization
34
+
35
+ ## Use Cases
36
+
37
+ IT incidents, software bugs, compliance violations, performance monitoring.
38
+
39
+ ## Documentation
40
+
41
+ - [Quick Start](docs/quickstart.md)
42
+ - [API Reference](docs/api-reference.md)
43
+ - [Methodology](docs/methodology.md)
@@ -0,0 +1,156 @@
1
+ # API Reference
2
+
3
+ ## Core Functions
4
+
5
+ ### fit_priority_matrix
6
+
7
+ ```python
8
+ from priorityx.core.glmm import fit_priority_matrix
9
+
10
+ results, stats = fit_priority_matrix(
11
+ df,
12
+ entity_col,
13
+ timestamp_col,
14
+ count_col=None,
15
+ date_filter=None,
16
+ min_observations=3,
17
+ min_total_count=0,
18
+ decline_window_quarters=6,
19
+ temporal_granularity="yearly",
20
+ vcp_p=3.5,
21
+ fe_p=3.0
22
+ )
23
+ ```
24
+
25
+ Fits Poisson GLMM to classify entities into priority quadrants.
26
+
27
+ **Parameters:**
28
+ - `df`: polars DataFrame
29
+ - `entity_col`: Entity identifier column name
30
+ - `timestamp_col`: Date column name
31
+ - `count_col`: Count metric column (optional, defaults to row count)
32
+ - `date_filter`: Date filter string (e.g., "< 2025-01-01")
33
+ - `min_observations`: Minimum time periods required
34
+ - `min_total_count`: Minimum total count threshold
35
+ - `decline_window_quarters`: Filter entities inactive >N quarters
36
+ - `temporal_granularity`: "yearly", "quarterly", or "semiannual"
37
+ - `vcp_p`: Random effects prior scale (default: 3.5)
38
+ - `fe_p`: Fixed effects prior scale (default: 3.0)
39
+
40
+ **Returns:**
41
+ - `results`: DataFrame with entity, Random_Intercept, Random_Slope, count, quadrant
42
+ - `stats`: Dictionary with model statistics
43
+
44
+ ---
45
+
46
+ ## Tracking Functions
47
+
48
+ ### track_cumulative_movement
49
+
50
+ ```python
51
+ from priorityx.tracking.movement import track_cumulative_movement
52
+
53
+ movement, meta = track_cumulative_movement(
54
+ df,
55
+ entity_col,
56
+ timestamp_col,
57
+ quarters=None,
58
+ min_total_count=20,
59
+ decline_window_quarters=6,
60
+ temporal_granularity="quarterly",
61
+ vcp_p=3.5,
62
+ fe_p=3.0
63
+ )
64
+ ```
65
+
66
+ Tracks entity movement through priority quadrants over time.
67
+
68
+ **Returns:**
69
+ - `movement`: DataFrame with quarterly X/Y positions
70
+ - `meta`: Dictionary with tracking metadata
71
+
72
+ ### extract_transitions
73
+
74
+ ```python
75
+ from priorityx.tracking.transitions import extract_transitions
76
+
77
+ transitions = extract_transitions(
78
+ movement_df,
79
+ focus_risk_increasing=True
80
+ )
81
+ ```
82
+
83
+ Extracts quadrant transitions from movement data.
84
+
85
+ **Returns:**
86
+ - DataFrame with transition details and risk levels
87
+
88
+ ---
89
+
90
+ ## Visualization Functions
91
+
92
+ ### plot_priority_matrix
93
+
94
+ ```python
95
+ from priorityx.viz.matrix import plot_priority_matrix
96
+
97
+ fig = plot_priority_matrix(
98
+ results_df,
99
+ entity_name="Entity",
100
+ figsize=(16, 12),
101
+ top_n_labels=5,
102
+ show_quadrant_labels=False,
103
+ save_plot=False,
104
+ output_dir="plot"
105
+ )
106
+ ```
107
+
108
+ Creates scatter plot of priority matrix.
109
+
110
+ ### plot_transition_timeline
111
+
112
+ ```python
113
+ from priorityx.viz.timeline import plot_transition_timeline
114
+
115
+ fig = plot_transition_timeline(
116
+ transitions_df,
117
+ entity_name="Entity",
118
+ filter_risk_levels=["critical", "high"],
119
+ max_entities=20,
120
+ save_plot=False,
121
+ output_dir="plot"
122
+ )
123
+ ```
124
+
125
+ Creates timeline heatmap of transitions.
126
+
127
+ ### plot_movement_trajectories
128
+
129
+ ```python
130
+ from priorityx.viz.trajectory import plot_movement_trajectories
131
+
132
+ fig = plot_movement_trajectories(
133
+ movement_df,
134
+ entity_name="Entity",
135
+ max_entities=10,
136
+ save_plot=False,
137
+ output_dir="plot"
138
+ )
139
+ ```
140
+
141
+ Creates trajectory plot showing movement through priority space.
142
+
143
+ ---
144
+
145
+ ## Utility Functions
146
+
147
+ ### Display Summaries
148
+
149
+ ```python
150
+ from priorityx.utils.helpers import display_quadrant_summary, display_transition_summary
151
+
152
+ display_quadrant_summary(results_df, entity_name="Service")
153
+ display_transition_summary(transitions_df, entity_name="Service")
154
+ ```
155
+
156
+ Prints formatted summaries of analysis results.