processsupport 0.1.0__py3-none-any.whl
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.
- processsupport/__init__.py +6 -0
- processsupport/_validation.py +64 -0
- processsupport/alignment.py +86 -0
- processsupport/baselines.py +119 -0
- processsupport/blasting.py +38 -0
- processsupport/energy.py +34 -0
- processsupport/kinetics.py +175 -0
- processsupport/observer.py +61 -0
- processsupport/particles.py +65 -0
- processsupport/quality.py +97 -0
- processsupport/reconciliation.py +102 -0
- processsupport/results.py +75 -0
- processsupport/settling.py +98 -0
- processsupport/spatial.py +225 -0
- processsupport/support.py +91 -0
- processsupport/transport.py +1226 -0
- processsupport/uncertainty.py +165 -0
- processsupport-0.1.0.dist-info/METADATA +78 -0
- processsupport-0.1.0.dist-info/RECORD +22 -0
- processsupport-0.1.0.dist-info/WHEEL +5 -0
- processsupport-0.1.0.dist-info/licenses/LICENSE +21 -0
- processsupport-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Finite-rank residual intervals and fixed-step delayed adaptive inference."""
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
import numpy as np
|
|
5
|
+
from ._validation import array, require
|
|
6
|
+
from .results import NumericalResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _interval(residuals, point, alpha):
|
|
10
|
+
n = len(residuals)
|
|
11
|
+
if alpha <= 0:
|
|
12
|
+
return None, None, "unbounded", None
|
|
13
|
+
if alpha >= 1:
|
|
14
|
+
return None, None, "empty", 0
|
|
15
|
+
rank = math.ceil((n + 1) * (1 - alpha))
|
|
16
|
+
if rank > n:
|
|
17
|
+
return None, None, "unbounded", rank
|
|
18
|
+
radius = float(np.partition(residuals, rank - 1)[rank - 1])
|
|
19
|
+
return float(point - radius), float(point + radius), "finite", rank
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def split_conformal(calibration_residuals, predictions, *, alpha=0.10, source_ids=()):
|
|
23
|
+
scores = np.abs(array(calibration_residuals, "calibration_residuals", 1))
|
|
24
|
+
point = array(predictions, "predictions", 1)
|
|
25
|
+
require(
|
|
26
|
+
np.isfinite(alpha) and 0 < alpha < 1,
|
|
27
|
+
"alpha",
|
|
28
|
+
"Split-conformal alpha must lie strictly between zero and one",
|
|
29
|
+
)
|
|
30
|
+
result = [_interval(scores, p, alpha) for p in point]
|
|
31
|
+
return NumericalResult(
|
|
32
|
+
dict(
|
|
33
|
+
lower=[r[0] for r in result], upper=[r[1] for r in result], interval_state=[r[2] for r in result]
|
|
34
|
+
),
|
|
35
|
+
dict(
|
|
36
|
+
rank=result[0][3],
|
|
37
|
+
calibration_count=len(scores),
|
|
38
|
+
alpha=alpha,
|
|
39
|
+
exchangeability_required=True,
|
|
40
|
+
conditional_safety_guarantee=False,
|
|
41
|
+
),
|
|
42
|
+
source_ids,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def aci(
|
|
47
|
+
predictions,
|
|
48
|
+
calibration_residuals,
|
|
49
|
+
released_targets,
|
|
50
|
+
*,
|
|
51
|
+
decision_times_s,
|
|
52
|
+
target_release_times_s,
|
|
53
|
+
availability_status,
|
|
54
|
+
forecast_ids,
|
|
55
|
+
timebase,
|
|
56
|
+
alpha=0.10,
|
|
57
|
+
gamma=0.01,
|
|
58
|
+
zero_latency=False,
|
|
59
|
+
source_ids=(),
|
|
60
|
+
):
|
|
61
|
+
require(
|
|
62
|
+
timebase in {"verified-utc-seconds", "verified-relative-seconds"},
|
|
63
|
+
"timebase",
|
|
64
|
+
"Online ACI requires a verified timebase",
|
|
65
|
+
)
|
|
66
|
+
p = array(predictions, "predictions", 1)
|
|
67
|
+
scores = np.abs(array(calibration_residuals, "calibration_residuals", 1))
|
|
68
|
+
target = array(released_targets, "released_targets", 1, finite=False)
|
|
69
|
+
decisions = array(decision_times_s, "decision_times_s", 1)
|
|
70
|
+
release = array(target_release_times_s, "target_release_times_s", 1, finite=False)
|
|
71
|
+
n = len(p)
|
|
72
|
+
names = list(forecast_ids)
|
|
73
|
+
statuses = list(availability_status)
|
|
74
|
+
require(
|
|
75
|
+
all(len(x) == n for x in [target, decisions, release, statuses, names]),
|
|
76
|
+
"shape",
|
|
77
|
+
"Forecast/release vectors must have equal lengths",
|
|
78
|
+
)
|
|
79
|
+
require(
|
|
80
|
+
len(set(names)) == n and all(isinstance(x, str) and x for x in names),
|
|
81
|
+
"identity",
|
|
82
|
+
"Forecast IDs must be unique nonempty strings",
|
|
83
|
+
)
|
|
84
|
+
require(np.all(np.diff(decisions) > 0), "event-order", "Decision times must increase strictly")
|
|
85
|
+
require(set(statuses) <= {"known", "bounded-upper", "unknown"}, "availability", "Unknown release status")
|
|
86
|
+
require(
|
|
87
|
+
np.isfinite(alpha) and np.isfinite(gamma) and gamma > 0,
|
|
88
|
+
"alpha",
|
|
89
|
+
"Finite alpha and positive fixed step are required",
|
|
90
|
+
)
|
|
91
|
+
known = np.array([s != "unknown" and np.isfinite(r) for s, r in zip(statuses, release)])
|
|
92
|
+
require(
|
|
93
|
+
np.all(release[known] >= decisions[known]),
|
|
94
|
+
"event-order",
|
|
95
|
+
"Target release cannot precede its forecast decision",
|
|
96
|
+
)
|
|
97
|
+
current = float(alpha)
|
|
98
|
+
lower = []
|
|
99
|
+
upper = []
|
|
100
|
+
states = []
|
|
101
|
+
ranks = []
|
|
102
|
+
used = []
|
|
103
|
+
updates = []
|
|
104
|
+
consumed = set()
|
|
105
|
+
|
|
106
|
+
def update_until(time, before_index, inclusive):
|
|
107
|
+
nonlocal current
|
|
108
|
+
ready = [
|
|
109
|
+
j
|
|
110
|
+
for j in range(before_index)
|
|
111
|
+
if j not in consumed
|
|
112
|
+
and known[j]
|
|
113
|
+
and np.isfinite(target[j])
|
|
114
|
+
and (release[j] <= time if inclusive else release[j] < time)
|
|
115
|
+
]
|
|
116
|
+
for j in sorted(ready, key=lambda j: (release[j], j)):
|
|
117
|
+
miss = (
|
|
118
|
+
0
|
|
119
|
+
if states[j] == "unbounded"
|
|
120
|
+
else 1
|
|
121
|
+
if states[j] == "empty"
|
|
122
|
+
else int(target[j] < lower[j] or target[j] > upper[j])
|
|
123
|
+
)
|
|
124
|
+
prior = current
|
|
125
|
+
current += gamma * (alpha - miss)
|
|
126
|
+
consumed.add(j)
|
|
127
|
+
updates.append(
|
|
128
|
+
dict(
|
|
129
|
+
forecast_id=names[j],
|
|
130
|
+
release_time_s=float(release[j]),
|
|
131
|
+
miss=miss,
|
|
132
|
+
alpha_before=prior,
|
|
133
|
+
alpha_after=current,
|
|
134
|
+
original_interval_state=states[j],
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
for i, decision in enumerate(decisions):
|
|
139
|
+
update_until(decision, i, bool(zero_latency))
|
|
140
|
+
used.append(current)
|
|
141
|
+
lo, hi, state, rank = _interval(scores, p[i], current)
|
|
142
|
+
lower.append(lo)
|
|
143
|
+
upper.append(hi)
|
|
144
|
+
states.append(state)
|
|
145
|
+
ranks.append(rank)
|
|
146
|
+
update_until(decision, i + 1, True)
|
|
147
|
+
return NumericalResult(
|
|
148
|
+
dict(lower=lower, upper=upper, interval_state=states),
|
|
149
|
+
dict(
|
|
150
|
+
alpha_used=used,
|
|
151
|
+
final_alpha=current,
|
|
152
|
+
target_alpha=alpha,
|
|
153
|
+
gamma=gamma,
|
|
154
|
+
ranks=ranks,
|
|
155
|
+
updates=updates,
|
|
156
|
+
updated_forecast_ids=[u["forecast_id"] for u in updates],
|
|
157
|
+
unknown_release_ids=[names[i] for i in range(n) if not known[i]],
|
|
158
|
+
same_instant_policy="earlier-forecasts-before-prediction"
|
|
159
|
+
if zero_latency
|
|
160
|
+
else "prediction-before-feedback",
|
|
161
|
+
calibration_scores="frozen",
|
|
162
|
+
conditional_safety_guarantee=False,
|
|
163
|
+
),
|
|
164
|
+
source_ids,
|
|
165
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: processsupport
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Auditable physical-support operators and constrained transport-response estimation
|
|
5
|
+
Author: Felipe Santibáñez-Leal
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/fsantibanezleal/CAOS_ProcessSupport
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy>=2.0
|
|
16
|
+
Requires-Dist: scipy>=1.14
|
|
17
|
+
Provides-Extra: spatial
|
|
18
|
+
Requires-Dist: PyKrige==1.7.3; extra == "spatial"
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest<10,>=9.1; extra == "test"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# ProcessSupport
|
|
24
|
+
|
|
25
|
+
Physical-support operators and constrained transport-response estimation for reproducible process data analysis. The independent Python distribution is `processsupport`; the repository contains the reusable numerical library, its tests and documentation. Display version 0.01.000 corresponds to distribution version 0.1.0.
|
|
26
|
+
|
|
27
|
+
The library preserves what an observation represents, when it was available and which physical quantities a model predicts. It supplies support-weighted composites, release-aware alignment, quality profiles, metric IDW and real PyKrige adapters, dimensional process references, constrained reconciliation, a Joseph-form linear observer, robust healthy-reference scores, finite-rank intervals and joint transport-response estimation.
|
|
28
|
+
|
|
29
|
+
## Install and calculate
|
|
30
|
+
|
|
31
|
+
Install the exact version with an isolated environment's Python. The optional `spatial` extra includes PyKrige 1.7.3. NumPy and SciPy are required; no neural training stack is imported.
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
python -m pip install "processsupport==0.1.0"
|
|
35
|
+
# Optional spatial interpolation engine:
|
|
36
|
+
python -m pip install "processsupport[spatial]==0.1.0"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from processsupport.support import composite
|
|
41
|
+
from processsupport.reconciliation import reconcile
|
|
42
|
+
|
|
43
|
+
grade = composite([1, 3], [1, 3], unit="%", basis="dry-solids",
|
|
44
|
+
weight_basis="mass", row_ids=["interval-a", "interval-b"])
|
|
45
|
+
assert grade.value == 2.5
|
|
46
|
+
flows = reconcile([10, 4, 5], [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
|
|
47
|
+
[[1, -1, -1]], [0])
|
|
48
|
+
print(flows.value) # [9.66666667, 4.33333333, 5.33333333]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
These are authored numerical examples, not measurements from a mine. `NumericalResult` retains NumPy arrays and diagnostics; `to_dict()` is JSON-safe. `ScientificRefusal` names an unsupported calculation instead of manufacturing a substitute answer. An unbounded interval uses an explicit state and null bounds. Unknown release time never becomes zero delay.
|
|
52
|
+
|
|
53
|
+
## Transport-response estimation
|
|
54
|
+
|
|
55
|
+
`processsupport.transport.SupportTransportRegressor` jointly fits a nonnegative normalized lag kernel and a linear response against known observation supports and optionally available physical balances. It uses eight starts, augmented least squares and analytic-gradient constrained SLSQP blocks. It retains convergence, physical output violations, identification rank, block-bootstrap and mean-lag profile evidence separately.
|
|
56
|
+
|
|
57
|
+
A predictive fit does not establish recovered residence time. Required bootstrap/profile diagnostics must finish before physical interpretation is admitted; weak excitation, unknown support, unseen regimes and numerical nonconvergence remain explicit refusals. There is no global-optimum, plant accuracy, novelty or superiority claim.
|
|
58
|
+
|
|
59
|
+
## Repository areas
|
|
60
|
+
|
|
61
|
+
- `src/processsupport/`: numerical core and serializable results.
|
|
62
|
+
- `tests/`: hand-calculated and independently manufactured numerical oracles, unit transformations and negative controls.
|
|
63
|
+
- `docs/`: [API](docs/api.md), [operator theory](docs/operators/operators.md), [design](docs/design/SDD.md), [frameworks](docs/frameworks/frameworks.md) and [own-data guide](docs/guides/guides.md).
|
|
64
|
+
- `scripts/`: matching PowerShell and shell local test entry points.
|
|
65
|
+
- `requirements-test.txt`: exact versions used for local scientific validation.
|
|
66
|
+
- `pyproject.toml`, `VERSION`, `CHANGELOG.md`: package metadata and coherent release version.
|
|
67
|
+
|
|
68
|
+
The library includes no dataset archive, pretrained model, frontend, API service or deployment. Consumer applications own data admission, leakage-safe evaluation, browser exports and scientific publications. Code is MIT licensed; external datasets and artifacts retain their own rights.
|
|
69
|
+
|
|
70
|
+
## Validate locally
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
python -m pip install -r requirements-test.txt
|
|
74
|
+
python -m pytest tests -q -p no:cacheprovider
|
|
75
|
+
python -m compileall -q src
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The numerical tests establish implementation behavior on their stated fixtures. They do not establish generalization across ore bodies, plants or operating regimes. See the [complete documentation](docs/README.md) before applying a reference model to physical data.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
processsupport/__init__.py,sha256=jnFKyhCufZCzBAV8-7aZS6kku-K4Bx5kSgRF_FUmMPc,260
|
|
2
|
+
processsupport/_validation.py,sha256=QkXWdoAdUru9iJVFBG2n0_fcIQYDnkDHzJP3WnVgkQ0,2103
|
|
3
|
+
processsupport/alignment.py,sha256=MwKOq40ljHveHU5vsAbriR55X7SroO11UX9A2shGZBk,3069
|
|
4
|
+
processsupport/baselines.py,sha256=Bt3QaDi3piWyZ6ffTvU3yIlbWyO1pAmPh0JbEEg83PY,4209
|
|
5
|
+
processsupport/blasting.py,sha256=UxMIwGOoQbvD6O_sh-Bljgr7nPxNdEPLlAeLIDJUVxU,1468
|
|
6
|
+
processsupport/energy.py,sha256=IL51Bp5raQtNpeZVyYBqgN-kZE8SiBCUp39zmIWW9QM,1158
|
|
7
|
+
processsupport/kinetics.py,sha256=tv7M8luOgSEX80Sq9FQKdNa72f064VgLCP-TUaF9-PI,6364
|
|
8
|
+
processsupport/observer.py,sha256=2se-kgK0R3KTvYcH_39MBpSLxAnJEMquyR91t64ZJXg,2581
|
|
9
|
+
processsupport/particles.py,sha256=npCB7H5fR37hoZ1wAQr2yKj3tkANIgZ-Kzl0ecv8YKo,2497
|
|
10
|
+
processsupport/quality.py,sha256=Ma79Usy_C9AxdfCD8Yuy76mA0VpTD85BOZJXGV5JLn0,3219
|
|
11
|
+
processsupport/reconciliation.py,sha256=vjjtrR2ePP8T_qqx88PAfQ-MDuUZItvslttZCHKhNw8,3891
|
|
12
|
+
processsupport/results.py,sha256=LCQO4F3TMStQOintCRcCoZIBqXG3LSQVpCkt7M21Y90,2186
|
|
13
|
+
processsupport/settling.py,sha256=JR1nSe1Dpl2wqZxAhXOR6LByWjSIyHsu5APdMFqc8oM,3213
|
|
14
|
+
processsupport/spatial.py,sha256=gfMg_rGnq3Iw8_XBe11-TRAjFsH3XuLPFFVgwDttdT0,8263
|
|
15
|
+
processsupport/support.py,sha256=fQNSm7w4OwCwpG_WYeZSIvD7FFSg_4VUUJrqz_kbzQg,2992
|
|
16
|
+
processsupport/transport.py,sha256=C4AhK3jEzTNdbb68fYPc-yntvdog0mO5i7c4-ZoB-F8,52394
|
|
17
|
+
processsupport/uncertainty.py,sha256=D91iNAZs8WZpSmaUFD5fPogRZBnMuNewaMDe8uiqo7Q,5542
|
|
18
|
+
processsupport-0.1.0.dist-info/licenses/LICENSE,sha256=tm3jvIbNSutX84gbXUFl1DvbwmqxRLvUULxZbA6ZhNI,1081
|
|
19
|
+
processsupport-0.1.0.dist-info/METADATA,sha256=BDqas9R-uD5cP0ZWhUvmZZd-zE5tCOc4YZ62MCQMZ6s,4895
|
|
20
|
+
processsupport-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
21
|
+
processsupport-0.1.0.dist-info/top_level.txt,sha256=eI62D1sSz0YXiI0HQd4L3c8SrChWU2WHjbBYtVoiu0w,15
|
|
22
|
+
processsupport-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Felipe Santibáñez-Leal
|
|
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 @@
|
|
|
1
|
+
processsupport
|