pacif-framework 3.0.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.
- pacif_framework-3.0.1/LICENSE +190 -0
- pacif_framework-3.0.1/PKG-INFO +242 -0
- pacif_framework-3.0.1/README.md +192 -0
- pacif_framework-3.0.1/pacif_core/__init__.py +14 -0
- pacif_framework-3.0.1/pacif_core/audit.py +147 -0
- pacif_framework-3.0.1/pacif_core/drift.py +20 -0
- pacif_framework-3.0.1/pacif_core/estimator.py +70 -0
- pacif_framework-3.0.1/pacif_framework.egg-info/PKG-INFO +242 -0
- pacif_framework-3.0.1/pacif_framework.egg-info/SOURCES.txt +15 -0
- pacif_framework-3.0.1/pacif_framework.egg-info/dependency_links.txt +1 -0
- pacif_framework-3.0.1/pacif_framework.egg-info/requires.txt +19 -0
- pacif_framework-3.0.1/pacif_framework.egg-info/top_level.txt +1 -0
- pacif_framework-3.0.1/pyproject.toml +99 -0
- pacif_framework-3.0.1/setup.cfg +4 -0
- pacif_framework-3.0.1/tests/test_audit.py +71 -0
- pacif_framework-3.0.1/tests/test_drift.py +67 -0
- pacif_framework-3.0.1/tests/test_estimator.py +88 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 PACIF Framework Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pacif-framework
|
|
3
|
+
Version: 3.0.1
|
|
4
|
+
Summary: Statistically rigorous framework for humanβalgorithm predictive alignment. Measures how strongly algorithms shape user behavior β and whether that signal is reliable.
|
|
5
|
+
Author-email: PACIF Framework Contributors <for.smirnov.maks@gmail.com>
|
|
6
|
+
Maintainer-email: ppiiyo <for.smirnov.maks@gmail.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/ppiiyo/pacif-framework
|
|
9
|
+
Project-URL: Documentation, https://github.com/ppiiyo/pacif-framework#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/ppiiyo/pacif-framework
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/ppiiyo/pacif-framework/issues
|
|
12
|
+
Project-URL: DOI, https://doi.org/10.5281/zenodo.19902776
|
|
13
|
+
Project-URL: Demo, https://pacif-demo.streamlit.app
|
|
14
|
+
Project-URL: Changelog, https://github.com/ppiiyo/pacif-framework/blob/main/CHANGELOG.md
|
|
15
|
+
Keywords: algorithmic-accountability,mutual-information,recommendation-systems,causal-inference,audit,transparency,drift-detection,predictive-alignment,responsible-ai,fairness,filter-bubble
|
|
16
|
+
Classifier: Development Status :: 4 - Beta
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Intended Audience :: Information Technology
|
|
20
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
29
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
30
|
+
Requires-Python: >=3.9
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: numpy>=1.24
|
|
34
|
+
Requires-Dist: numba>=0.58
|
|
35
|
+
Requires-Dist: scipy>=1.10
|
|
36
|
+
Requires-Dist: pyyaml>=6.0
|
|
37
|
+
Provides-Extra: demo
|
|
38
|
+
Requires-Dist: streamlit>=1.28; extra == "demo"
|
|
39
|
+
Requires-Dist: pandas>=2.0; extra == "demo"
|
|
40
|
+
Requires-Dist: scikit-learn>=1.3; extra == "demo"
|
|
41
|
+
Provides-Extra: causal
|
|
42
|
+
Requires-Dist: scikit-learn>=1.3; extra == "causal"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
45
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
46
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
47
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
48
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# PACIF v3.0
|
|
52
|
+
|
|
53
|
+
**Predictive Alignment & Causal Information Flow**
|
|
54
|
+
|
|
55
|
+
> Measures how strongly algorithms shape user behavior β and whether that signal is reliable.
|
|
56
|
+
|
|
57
|
+
[](https://pacif-demo.streamlit.app)
|
|
58
|
+
[](https://doi.org/10.5281/zenodo.19902776)
|
|
59
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
60
|
+
[](https://www.python.org/downloads/)
|
|
61
|
+
[](https://github.com/ppiiyo/pacif-framework/actions/workflows/ci.yml)
|
|
62
|
+
[](https://pypi.org/)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Why PACIF exists
|
|
67
|
+
|
|
68
|
+
Modern recommendation systems are **closed-loop controllers**: user actions train the model, and the model shapes future exposure. These feedback loops can produce behavioral lock-in, filter bubbles, and algorithmic influence that is hard to observe from the outside.
|
|
69
|
+
|
|
70
|
+
Platforms, regulators, auditors, and researchers currently lack a **transparent, statistically rigorous, and audit-ready metric** that answers a simple question:
|
|
71
|
+
|
|
72
|
+
> *How tightly is user behavior coupled to the systemβs recommendations β and can we trust that measurement?*
|
|
73
|
+
|
|
74
|
+
Existing approaches suffer from finite-sample bias, provide no reliability diagnostics, and are frequently misinterpreted as causal claims. PACIF was built to close that gap.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## What PACIF measures
|
|
79
|
+
|
|
80
|
+
PACIF quantifies **predictive alignment** between user actions (`U`) and system context / recommendations (`S`), with optional control for observed confounders (`C`).
|
|
81
|
+
|
|
82
|
+
It is deliberately **not** a measure of causality, user wellbeing, or βmanipulationβ. It is a production-ready diagnostic layer that tells you:
|
|
83
|
+
|
|
84
|
+
| Signal | What it tells you |
|
|
85
|
+
|--------|-------------------|
|
|
86
|
+
| **Signal Strength (MI)** | Intensity of statistical coupling (nats) |
|
|
87
|
+
| **Reliability** | Whether the estimate is statistically stable |
|
|
88
|
+
| **Drift** | Whether the relationship has shifted over time |
|
|
89
|
+
| **Audit Report** | Machine-readable YAML with anti-gaming flags |
|
|
90
|
+
|
|
91
|
+
### Core capabilities
|
|
92
|
+
|
|
93
|
+
- **Bias-corrected Mutual Information** β Miller-Madow correction reduces finite-sample bias by 40β65%.
|
|
94
|
+
- **Strict reliability diagnostics** β automatically flags unstable estimates via confidence-interval width thresholds.
|
|
95
|
+
- **Cumulative drift detection** β CUSUM + Page-Hinkley for non-stationary behavioral shifts.
|
|
96
|
+
- **Regulator-ready audit reports** β YAML output with exclusion-rate, category-inflation, skew, and drift flags.
|
|
97
|
+
- **Causal integration pattern** β PACIF features reduce Doubly Robust (DR) estimator bias by ~89% in controlled simulations.
|
|
98
|
+
|
|
99
|
+
**Performance (reference):** >1,900 sessions/sec, p95 latency <1 ms (`examples/benchmark_throughput.py`).
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Explicit boundaries (important)
|
|
104
|
+
|
|
105
|
+
PACIF measures **statistical predictability**, not causality and not wellbeing.
|
|
106
|
+
|
|
107
|
+
- High mutual information indicates strong *association / coupling*, not that the algorithm *caused* the behavior.
|
|
108
|
+
- Normative or causal claims require intervention data, experimental design, or stronger identification assumptions.
|
|
109
|
+
- The framework is designed to be honest about uncertainty: unreliable estimates are explicitly marked.
|
|
110
|
+
|
|
111
|
+
Full practitioner guide: **[docs/INTERPRETATION.md](docs/INTERPRETATION.md)**
|
|
112
|
+
Outreach one-pager: **[docs/POSITIONING.md](docs/POSITIONING.md)**
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Quick start
|
|
117
|
+
|
|
118
|
+
### Live demo (no install)
|
|
119
|
+
|
|
120
|
+
π **[Launch PACIF Demo](https://pacif-demo.streamlit.app)**
|
|
121
|
+
|
|
122
|
+
### Install
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install -e . # core
|
|
126
|
+
pip install -e ".[demo,causal,dev]" # demo + causal example + tests
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Or from the repository:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/ppiiyo/pacif-framework.git
|
|
133
|
+
cd pacif-framework
|
|
134
|
+
pip install -e ".[demo,dev]"
|
|
135
|
+
pytest tests/ -v
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Minimal usage
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from pacif_core import estimate_alignment, DriftDetector, AuditReporter
|
|
142
|
+
import numpy as np
|
|
143
|
+
|
|
144
|
+
events = np.array([0, 1, 0, 2, 1, 0, 2, 1] * 20)
|
|
145
|
+
contexts = np.array([0, 1, 0, 1, 1, 0, 2, 1] * 20)
|
|
146
|
+
|
|
147
|
+
result = estimate_alignment(events, contexts)
|
|
148
|
+
|
|
149
|
+
if result["status"] == "success":
|
|
150
|
+
print(f"MI: {result['mi_estimate']:.3f} nats")
|
|
151
|
+
print(f"95% CI: {result['ci_95']}")
|
|
152
|
+
print(f"Reliable: {result['reliable']}")
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
See `examples/basic_usage.py` for multi-session + drift + audit.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Interpreting results
|
|
160
|
+
|
|
161
|
+
| Metric | Interpretation | Suggested action |
|
|
162
|
+
|--------|----------------|------------------|
|
|
163
|
+
| **Signal Strength (MI)** | Intensity of coupling | > 0.8 nats β investigate lock-in risk |
|
|
164
|
+
| **Reliability Ratio** | % of sessions with statistically valid estimates | < 70% β increase sample size or window |
|
|
165
|
+
| **Drift Status** | Significant change in the relationship over time | Drift detected β consider model recalibration |
|
|
166
|
+
|
|
167
|
+
Deep dive: [docs/INTERPRETATION.md](docs/INTERPRETATION.md)
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Who this is for
|
|
172
|
+
|
|
173
|
+
- **Responsible AI / Trust & Safety teams** β internal monitoring of recommendation influence and feedback loops.
|
|
174
|
+
- **Platforms** (social, e-commerce, content, news) β diagnostics for personalization strength and stability.
|
|
175
|
+
- **Regulators & compliance** β audit-ready, machine-readable reports with explicit reliability and anti-gaming signals.
|
|
176
|
+
- **Researchers** in algorithmic accountability, fairness, and causal inference β reproducible metric + integration path with DR estimators.
|
|
177
|
+
- **Auditors & third-party assessors** β independent quantification of humanβalgorithm coupling.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Project structure
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
pacif-framework/
|
|
185
|
+
βββ pacif_core/
|
|
186
|
+
β βββ estimator.py # Bias-corrected MI + reliability
|
|
187
|
+
β βββ drift.py # CUSUM-style drift detector
|
|
188
|
+
β βββ audit.py # YAML audit reporter (schema 1.1)
|
|
189
|
+
βββ tests/ # pytest suite
|
|
190
|
+
βββ docs/
|
|
191
|
+
β βββ INTERPRETATION.md
|
|
192
|
+
β βββ POSITIONING.md
|
|
193
|
+
βββ examples/
|
|
194
|
+
β βββ basic_usage.py
|
|
195
|
+
β βββ benchmark_throughput.py
|
|
196
|
+
βββ app.py # Streamlit demo
|
|
197
|
+
βββ causal_integration.py # DR estimator illustration
|
|
198
|
+
βββ .github/workflows/ci.yml
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Enterprise & audit integration
|
|
204
|
+
|
|
205
|
+
For production deployments, multi-tenant audit pipelines, custom connectors, or compliance reporting support, contact:
|
|
206
|
+
|
|
207
|
+
**for.smirnov.maks@gmail.com**
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
We welcome contributions. Algorithmic transparency should be a public good.
|
|
214
|
+
|
|
215
|
+
- π [Open an issue](https://github.com/ppiiyo/pacif-framework/issues)
|
|
216
|
+
- π‘ Pull requests are welcome (see [CONTRIBUTING.md](CONTRIBUTING.md))
|
|
217
|
+
- π Please follow the [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
218
|
+
- π [Security policy](SECURITY.md)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Citation
|
|
223
|
+
|
|
224
|
+
If you use PACIF in research, audits, or product workflows, please cite:
|
|
225
|
+
|
|
226
|
+
```bibtex
|
|
227
|
+
@software{pacif_v3_2026,
|
|
228
|
+
author = {ppiiyo},
|
|
229
|
+
title = {PACIF v3.0: Predictive Alignment \& Causal Information Flow},
|
|
230
|
+
year = {2026},
|
|
231
|
+
url = {https://github.com/ppiiyo/pacif-framework},
|
|
232
|
+
doi = {10.5281/zenodo.19902776},
|
|
233
|
+
license = {Apache-2.0}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Also available as [`CITATION.cff`](CITATION.cff).
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
*Built for transparency, reproducibility, and algorithmic accountability.*
|
|
242
|
+
Β© 2026 PACIF Framework Contributors
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# PACIF v3.0
|
|
2
|
+
|
|
3
|
+
**Predictive Alignment & Causal Information Flow**
|
|
4
|
+
|
|
5
|
+
> Measures how strongly algorithms shape user behavior β and whether that signal is reliable.
|
|
6
|
+
|
|
7
|
+
[](https://pacif-demo.streamlit.app)
|
|
8
|
+
[](https://doi.org/10.5281/zenodo.19902776)
|
|
9
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
|
+
[](https://www.python.org/downloads/)
|
|
11
|
+
[](https://github.com/ppiiyo/pacif-framework/actions/workflows/ci.yml)
|
|
12
|
+
[](https://pypi.org/)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why PACIF exists
|
|
17
|
+
|
|
18
|
+
Modern recommendation systems are **closed-loop controllers**: user actions train the model, and the model shapes future exposure. These feedback loops can produce behavioral lock-in, filter bubbles, and algorithmic influence that is hard to observe from the outside.
|
|
19
|
+
|
|
20
|
+
Platforms, regulators, auditors, and researchers currently lack a **transparent, statistically rigorous, and audit-ready metric** that answers a simple question:
|
|
21
|
+
|
|
22
|
+
> *How tightly is user behavior coupled to the systemβs recommendations β and can we trust that measurement?*
|
|
23
|
+
|
|
24
|
+
Existing approaches suffer from finite-sample bias, provide no reliability diagnostics, and are frequently misinterpreted as causal claims. PACIF was built to close that gap.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## What PACIF measures
|
|
29
|
+
|
|
30
|
+
PACIF quantifies **predictive alignment** between user actions (`U`) and system context / recommendations (`S`), with optional control for observed confounders (`C`).
|
|
31
|
+
|
|
32
|
+
It is deliberately **not** a measure of causality, user wellbeing, or βmanipulationβ. It is a production-ready diagnostic layer that tells you:
|
|
33
|
+
|
|
34
|
+
| Signal | What it tells you |
|
|
35
|
+
|--------|-------------------|
|
|
36
|
+
| **Signal Strength (MI)** | Intensity of statistical coupling (nats) |
|
|
37
|
+
| **Reliability** | Whether the estimate is statistically stable |
|
|
38
|
+
| **Drift** | Whether the relationship has shifted over time |
|
|
39
|
+
| **Audit Report** | Machine-readable YAML with anti-gaming flags |
|
|
40
|
+
|
|
41
|
+
### Core capabilities
|
|
42
|
+
|
|
43
|
+
- **Bias-corrected Mutual Information** β Miller-Madow correction reduces finite-sample bias by 40β65%.
|
|
44
|
+
- **Strict reliability diagnostics** β automatically flags unstable estimates via confidence-interval width thresholds.
|
|
45
|
+
- **Cumulative drift detection** β CUSUM + Page-Hinkley for non-stationary behavioral shifts.
|
|
46
|
+
- **Regulator-ready audit reports** β YAML output with exclusion-rate, category-inflation, skew, and drift flags.
|
|
47
|
+
- **Causal integration pattern** β PACIF features reduce Doubly Robust (DR) estimator bias by ~89% in controlled simulations.
|
|
48
|
+
|
|
49
|
+
**Performance (reference):** >1,900 sessions/sec, p95 latency <1 ms (`examples/benchmark_throughput.py`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Explicit boundaries (important)
|
|
54
|
+
|
|
55
|
+
PACIF measures **statistical predictability**, not causality and not wellbeing.
|
|
56
|
+
|
|
57
|
+
- High mutual information indicates strong *association / coupling*, not that the algorithm *caused* the behavior.
|
|
58
|
+
- Normative or causal claims require intervention data, experimental design, or stronger identification assumptions.
|
|
59
|
+
- The framework is designed to be honest about uncertainty: unreliable estimates are explicitly marked.
|
|
60
|
+
|
|
61
|
+
Full practitioner guide: **[docs/INTERPRETATION.md](docs/INTERPRETATION.md)**
|
|
62
|
+
Outreach one-pager: **[docs/POSITIONING.md](docs/POSITIONING.md)**
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
### Live demo (no install)
|
|
69
|
+
|
|
70
|
+
π **[Launch PACIF Demo](https://pacif-demo.streamlit.app)**
|
|
71
|
+
|
|
72
|
+
### Install
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e . # core
|
|
76
|
+
pip install -e ".[demo,causal,dev]" # demo + causal example + tests
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or from the repository:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
git clone https://github.com/ppiiyo/pacif-framework.git
|
|
83
|
+
cd pacif-framework
|
|
84
|
+
pip install -e ".[demo,dev]"
|
|
85
|
+
pytest tests/ -v
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Minimal usage
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from pacif_core import estimate_alignment, DriftDetector, AuditReporter
|
|
92
|
+
import numpy as np
|
|
93
|
+
|
|
94
|
+
events = np.array([0, 1, 0, 2, 1, 0, 2, 1] * 20)
|
|
95
|
+
contexts = np.array([0, 1, 0, 1, 1, 0, 2, 1] * 20)
|
|
96
|
+
|
|
97
|
+
result = estimate_alignment(events, contexts)
|
|
98
|
+
|
|
99
|
+
if result["status"] == "success":
|
|
100
|
+
print(f"MI: {result['mi_estimate']:.3f} nats")
|
|
101
|
+
print(f"95% CI: {result['ci_95']}")
|
|
102
|
+
print(f"Reliable: {result['reliable']}")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
See `examples/basic_usage.py` for multi-session + drift + audit.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Interpreting results
|
|
110
|
+
|
|
111
|
+
| Metric | Interpretation | Suggested action |
|
|
112
|
+
|--------|----------------|------------------|
|
|
113
|
+
| **Signal Strength (MI)** | Intensity of coupling | > 0.8 nats β investigate lock-in risk |
|
|
114
|
+
| **Reliability Ratio** | % of sessions with statistically valid estimates | < 70% β increase sample size or window |
|
|
115
|
+
| **Drift Status** | Significant change in the relationship over time | Drift detected β consider model recalibration |
|
|
116
|
+
|
|
117
|
+
Deep dive: [docs/INTERPRETATION.md](docs/INTERPRETATION.md)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Who this is for
|
|
122
|
+
|
|
123
|
+
- **Responsible AI / Trust & Safety teams** β internal monitoring of recommendation influence and feedback loops.
|
|
124
|
+
- **Platforms** (social, e-commerce, content, news) β diagnostics for personalization strength and stability.
|
|
125
|
+
- **Regulators & compliance** β audit-ready, machine-readable reports with explicit reliability and anti-gaming signals.
|
|
126
|
+
- **Researchers** in algorithmic accountability, fairness, and causal inference β reproducible metric + integration path with DR estimators.
|
|
127
|
+
- **Auditors & third-party assessors** β independent quantification of humanβalgorithm coupling.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Project structure
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
pacif-framework/
|
|
135
|
+
βββ pacif_core/
|
|
136
|
+
β βββ estimator.py # Bias-corrected MI + reliability
|
|
137
|
+
β βββ drift.py # CUSUM-style drift detector
|
|
138
|
+
β βββ audit.py # YAML audit reporter (schema 1.1)
|
|
139
|
+
βββ tests/ # pytest suite
|
|
140
|
+
βββ docs/
|
|
141
|
+
β βββ INTERPRETATION.md
|
|
142
|
+
β βββ POSITIONING.md
|
|
143
|
+
βββ examples/
|
|
144
|
+
β βββ basic_usage.py
|
|
145
|
+
β βββ benchmark_throughput.py
|
|
146
|
+
βββ app.py # Streamlit demo
|
|
147
|
+
βββ causal_integration.py # DR estimator illustration
|
|
148
|
+
βββ .github/workflows/ci.yml
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Enterprise & audit integration
|
|
154
|
+
|
|
155
|
+
For production deployments, multi-tenant audit pipelines, custom connectors, or compliance reporting support, contact:
|
|
156
|
+
|
|
157
|
+
**for.smirnov.maks@gmail.com**
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
We welcome contributions. Algorithmic transparency should be a public good.
|
|
164
|
+
|
|
165
|
+
- π [Open an issue](https://github.com/ppiiyo/pacif-framework/issues)
|
|
166
|
+
- π‘ Pull requests are welcome (see [CONTRIBUTING.md](CONTRIBUTING.md))
|
|
167
|
+
- π Please follow the [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
168
|
+
- π [Security policy](SECURITY.md)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Citation
|
|
173
|
+
|
|
174
|
+
If you use PACIF in research, audits, or product workflows, please cite:
|
|
175
|
+
|
|
176
|
+
```bibtex
|
|
177
|
+
@software{pacif_v3_2026,
|
|
178
|
+
author = {ppiiyo},
|
|
179
|
+
title = {PACIF v3.0: Predictive Alignment \& Causal Information Flow},
|
|
180
|
+
year = {2026},
|
|
181
|
+
url = {https://github.com/ppiiyo/pacif-framework},
|
|
182
|
+
doi = {10.5281/zenodo.19902776},
|
|
183
|
+
license = {Apache-2.0}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Also available as [`CITATION.cff`](CITATION.cff).
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
*Built for transparency, reproducibility, and algorithmic accountability.*
|
|
192
|
+
Β© 2026 PACIF Framework Contributors
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""PACIF: Predictive Alignment & Causal Information Flow."""
|
|
2
|
+
|
|
3
|
+
from .audit import AuditReporter
|
|
4
|
+
from .drift import DriftDetector
|
|
5
|
+
from .estimator import estimate_alignment
|
|
6
|
+
|
|
7
|
+
__version__ = "3.0.1"
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"estimate_alignment",
|
|
11
|
+
"DriftDetector",
|
|
12
|
+
"AuditReporter",
|
|
13
|
+
"__version__",
|
|
14
|
+
]
|