eb-optimization 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/LICENSE +28 -28
  2. {eb_optimization-0.1.0/src/eb_optimization.egg-info → eb_optimization-0.2.0}/PKG-INFO +124 -117
  3. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/README.md +86 -81
  4. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/pyproject.toml +105 -103
  5. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/setup.cfg +4 -4
  6. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/__init__.py +37 -37
  7. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/_utils.py +121 -121
  8. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/policies/__init__.py +75 -73
  9. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/policies/cost_ratio_policy.py +293 -293
  10. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/policies/ral_policy.py +162 -129
  11. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/policies/tau_policy.py +155 -155
  12. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/search/__init__.py +31 -26
  13. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/search/grid.py +90 -90
  14. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/search/kernels.py +114 -114
  15. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/tuning/__init__.py +31 -26
  16. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/tuning/cost_ratio.py +269 -269
  17. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/tuning/ral.py +143 -143
  18. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/tuning/sensitivity.py +318 -318
  19. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/tuning/tau.py +509 -509
  20. {eb_optimization-0.1.0 → eb_optimization-0.2.0/src/eb_optimization.egg-info}/PKG-INFO +124 -117
  21. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization.egg-info/SOURCES.txt +2 -1
  22. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization.egg-info/requires.txt +2 -0
  23. eb_optimization-0.2.0/tests/test_public_api.py +39 -0
  24. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization/search/results.py +0 -0
  25. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization.egg-info/dependency_links.txt +0 -0
  26. {eb_optimization-0.1.0 → eb_optimization-0.2.0}/src/eb_optimization.egg-info/top_level.txt +0 -0
@@ -1,28 +1,28 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2025, Kyle Corrie
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are met:
7
-
8
- 1. Redistributions of source code must retain the above copyright notice, this
9
- list of conditions and the following disclaimer.
10
-
11
- 2. Redistributions in binary form must reproduce the above copyright notice,
12
- this list of conditions and the following disclaimer in the documentation
13
- and/or other materials provided with the distribution.
14
-
15
- 3. Neither the name of the copyright holder nor the names of its
16
- contributors may be used to endorse or promote products derived from
17
- this software without specific prior written permission.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Kyle Corrie
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,117 +1,124 @@
1
- Metadata-Version: 2.4
2
- Name: eb-optimization
3
- Version: 0.1.0
4
- Summary: Electric Barometer: Optimization and tuning utilities for EB objectives and policy parameters.
5
- Author-email: "Kyle Corrie (Economistician)" <kcorrie@economistician.com>
6
- License-Expression: BSD-3-Clause
7
- Project-URL: Homepage, https://github.com/Economistician/eb-optimization
8
- Project-URL: Repository, https://github.com/Economistician/eb-optimization
9
- Project-URL: Issues, https://github.com/Economistician/eb-optimization/issues
10
- Project-URL: Documentation, https://github.com/Economistician/eb-docs
11
- Keywords: electric-barometer,optimization,tuning,grid-search,calibration,asymmetric-loss,forecasting,pandas
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Classifier: Programming Language :: Python :: 3.13
18
- Classifier: Operating System :: OS Independent
19
- Requires-Python: >=3.10
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE
22
- Requires-Dist: numpy>=1.24
23
- Requires-Dist: pandas>=2.0
24
- Provides-Extra: eb
25
- Requires-Dist: eb-metrics<0.3,>=0.2; extra == "eb"
26
- Requires-Dist: eb-evaluation<0.3,>=0.2; extra == "eb"
27
- Provides-Extra: opt
28
- Provides-Extra: test
29
- Requires-Dist: pytest>=8.0; extra == "test"
30
- Requires-Dist: scikit-learn>=1.3; extra == "test"
31
- Provides-Extra: dev
32
- Requires-Dist: pytest>=8.0; extra == "dev"
33
- Requires-Dist: pytest-cov>=5.0; extra == "dev"
34
- Dynamic: license-file
35
-
36
- # Electric Barometer · Optimization (`eb-optimization`)
37
-
38
- Decision and policy layer for the Electric Barometer ecosystem, responsible for tuning, calibration, and governed parameter selection.
39
-
40
- ---
41
-
42
- ## Overview
43
-
44
- This repository contains the optimization, tuning, and policy governance layer of the Electric Barometer ecosystem. It defines how key evaluation parameters—such as cost ratios, tolerances, and readiness controls—are selected from data, validated under governance rules, and formalized into deterministic policies that can be reused across systems and environments.
45
-
46
- Rather than computing metrics or running evaluations, this repository focuses on decision logic: how parameters are calibrated, how tradeoffs are resolved, and how those decisions are frozen into auditable artifacts. It provides the bridge between metric theory and operational deployment, ensuring that forecast evaluation behavior is consistent, explainable, and governed by explicit intent rather than ad-hoc configuration.
47
-
48
- ---
49
-
50
- ## Role in the Electric Barometer Ecosystem
51
-
52
- `eb-optimization` defines the parameter selection, calibration, and governance logic used throughout the Electric Barometer ecosystem. It is responsible for determining how key operational parameters—such as cost ratios, tolerance bands, and readiness controls—are selected from data in a disciplined, reproducible, and decision-aware manner.
53
-
54
- This repository focuses exclusively on optimization mechanics and policy formation. It does not define metric primitives, perform evaluation orchestration, manage model interfaces, or execute runtime decision logic. Those responsibilities are handled by adjacent layers in the ecosystem that compute metrics, evaluate forecasts, or apply frozen policies in production workflows.
55
-
56
- By separating parameter selection and governance from metric semantics and execution concerns, eb-optimization provides a stable optimization layer that enables consistent calibration, transparent decision rules, and auditable policy artifacts across heterogeneous forecasting and operational contexts.
57
-
58
- ---
59
-
60
- ## Installation
61
-
62
- `eb-optimization` is distributed as a standard Python package.
63
-
64
- ```bash
65
- pip install eb-optimization
66
- ```
67
-
68
- ---
69
-
70
- ## Core Concepts
71
-
72
- - **Parameter governance** — Operational parameters (e.g., cost ratios, tolerances) should be selected through explicit, reproducible rules rather than ad-hoc tuning or implicit defaults.
73
- - **Search over candidate spaces** — Optimization is framed as deterministic search over bounded, interpretable candidate sets, enabling transparent tradeoffs and stable outcomes.
74
- - **Cost balance calibration** — Asymmetric operational costs can be balanced by selecting parameters that equalize or appropriately trade off opposing risk exposures.
75
- - **Tolerance selection from residuals** — Acceptable error bands can be learned directly from historical performance, reflecting empirical system behavior rather than arbitrary thresholds.
76
- - **Policy separation** — Calibration logic is separated from frozen policy artifacts so that parameter selection is auditable, versioned, and safely applied in downstream systems.
77
- - **Decision-aligned optimization** — Optimization is evaluated by operational interpretability and governance fitness, not by abstract numerical optimality alone.
78
-
79
- ---
80
-
81
- ## Minimal Example
82
-
83
- The example below illustrates a typical optimization workflow using `eb-optimization`: calibrating an operational parameter from historical data and applying it via a frozen policy.
84
-
85
- ```python
86
- import numpy as np
87
- from eb_optimization.policies import (
88
- CostRatioPolicy,
89
- apply_cost_ratio_policy,
90
- )
91
-
92
- # Historical actuals and forecasts
93
- y_true = np.array([10, 12, 15, 20])
94
- y_pred = np.array([9, 14, 18, 17])
95
-
96
- # Define a frozen cost-ratio policy
97
- policy = CostRatioPolicy(
98
- R_grid=(0.5, 1.0, 2.0, 3.0),
99
- co=1.0,
100
- )
101
-
102
- # Estimate a global cost ratio R
103
- R, diagnostics = apply_cost_ratio_policy(
104
- y_true=y_true,
105
- y_pred=y_pred,
106
- policy=policy,
107
- )
108
-
109
- print(R)
110
- ```
111
-
112
- ---
113
-
114
- ## License
115
-
116
- BSD 3-Clause License.
117
- © 2025 Kyle Corrie.
1
+ Metadata-Version: 2.4
2
+ Name: eb-optimization
3
+ Version: 0.2.0
4
+ Summary: Electric Barometer: Optimization and tuning utilities for EB objectives and policy parameters.
5
+ Author-email: "Kyle Corrie (Economistician)" <kcorrie@economistician.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/Economistician/eb-optimization
8
+ Project-URL: Repository, https://github.com/Economistician/eb-optimization
9
+ Project-URL: Issues, https://github.com/Economistician/eb-optimization/issues
10
+ Project-URL: Documentation, https://github.com/Economistician/eb-docs
11
+ Keywords: electric-barometer,optimization,tuning,grid-search,calibration,asymmetric-loss,forecasting,pandas
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy>=1.24
23
+ Requires-Dist: pandas>=2.0
24
+ Provides-Extra: eb
25
+ Requires-Dist: eb-metrics<0.3,>=0.2; extra == "eb"
26
+ Requires-Dist: eb-evaluation<0.3,>=0.2; extra == "eb"
27
+ Provides-Extra: opt
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=8.0; extra == "test"
30
+ Requires-Dist: scikit-learn>=1.3; extra == "test"
31
+ Requires-Dist: eb-optimization[eb]; extra == "test"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
35
+ Requires-Dist: eb-optimization[eb]; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # Electric Barometer · Optimization (`eb-optimization`)
39
+
40
+ [![CI](https://github.com/Economistician/eb-optimization/actions/workflows/ci.yml/badge.svg)](https://github.com/Economistician/eb-optimization/actions/workflows/ci.yml)
41
+ ![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)
42
+ ![Python Versions](https://img.shields.io/pypi/pyversions/eb-optimization)
43
+ ![PyPI](https://img.shields.io/pypi/v/eb-optimization)
44
+
45
+ Decision and policy layer for the Electric Barometer ecosystem, responsible for tuning, calibration, and governed parameter selection.
46
+
47
+ ---
48
+
49
+ ## Overview
50
+
51
+ This repository contains the optimization, tuning, and policy governance layer of the Electric Barometer ecosystem. It defines how key evaluation parameters—such as cost ratios, tolerances, and readiness controls—are selected from data, validated under governance rules, and formalized into deterministic policies that can be reused across systems and environments.
52
+
53
+ Rather than computing metrics or running evaluations, this repository focuses on decision logic: how parameters are calibrated, how tradeoffs are resolved, and how those decisions are frozen into auditable artifacts. It provides the bridge between metric theory and operational deployment, ensuring that forecast evaluation behavior is consistent, explainable, and governed by explicit intent rather than ad-hoc configuration.
54
+
55
+ ---
56
+
57
+ ## Role in the Electric Barometer Ecosystem
58
+
59
+ `eb-optimization` defines the parameter selection, calibration, and governance logic used throughout the Electric Barometer ecosystem. It is responsible for determining how key operational parameters—such as cost ratios, tolerance bands, and readiness controls—are selected from data in a disciplined, reproducible, and decision-aware manner.
60
+
61
+ This repository focuses exclusively on optimization mechanics and policy formation. It does not define metric primitives, perform evaluation orchestration, manage model interfaces, or execute runtime decision logic. Those responsibilities are handled by adjacent layers in the ecosystem that compute metrics, evaluate forecasts, or apply frozen policies in production workflows.
62
+
63
+ By separating parameter selection and governance from metric semantics and execution concerns, eb-optimization provides a stable optimization layer that enables consistent calibration, transparent decision rules, and auditable policy artifacts across heterogeneous forecasting and operational contexts.
64
+
65
+ ---
66
+
67
+ ## Installation
68
+
69
+ `eb-optimization` is distributed as a standard Python package.
70
+
71
+ ```bash
72
+ pip install eb-optimization
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Core Concepts
78
+
79
+ - **Parameter governance** — Operational parameters (e.g., cost ratios, tolerances) should be selected through explicit, reproducible rules rather than ad-hoc tuning or implicit defaults.
80
+ - **Search over candidate spaces** — Optimization is framed as deterministic search over bounded, interpretable candidate sets, enabling transparent tradeoffs and stable outcomes.
81
+ - **Cost balance calibration** — Asymmetric operational costs can be balanced by selecting parameters that equalize or appropriately trade off opposing risk exposures.
82
+ - **Tolerance selection from residuals** — Acceptable error bands can be learned directly from historical performance, reflecting empirical system behavior rather than arbitrary thresholds.
83
+ - **Policy separation** — Calibration logic is separated from frozen policy artifacts so that parameter selection is auditable, versioned, and safely applied in downstream systems.
84
+ - **Decision-aligned optimization** — Optimization is evaluated by operational interpretability and governance fitness, not by abstract numerical optimality alone.
85
+
86
+ ---
87
+
88
+ ## Minimal Example
89
+
90
+ The example below illustrates a typical optimization workflow using `eb-optimization`: calibrating an operational parameter from historical data and applying it via a frozen policy.
91
+
92
+ ```python
93
+ import numpy as np
94
+ from eb_optimization.policies import (
95
+ CostRatioPolicy,
96
+ apply_cost_ratio_policy,
97
+ )
98
+
99
+ # Historical actuals and forecasts
100
+ y_true = np.array([10, 12, 15, 20])
101
+ y_pred = np.array([9, 14, 18, 17])
102
+
103
+ # Define a frozen cost-ratio policy
104
+ policy = CostRatioPolicy(
105
+ R_grid=(0.5, 1.0, 2.0, 3.0),
106
+ co=1.0,
107
+ )
108
+
109
+ # Estimate a global cost ratio R
110
+ R, diagnostics = apply_cost_ratio_policy(
111
+ y_true=y_true,
112
+ y_pred=y_pred,
113
+ policy=policy,
114
+ )
115
+
116
+ print(R)
117
+ ```
118
+
119
+ ---
120
+
121
+ ## License
122
+
123
+ BSD 3-Clause License.
124
+ © 2025 Kyle Corrie.
@@ -1,82 +1,87 @@
1
- # Electric Barometer · Optimization (`eb-optimization`)
2
-
3
- Decision and policy layer for the Electric Barometer ecosystem, responsible for tuning, calibration, and governed parameter selection.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- This repository contains the optimization, tuning, and policy governance layer of the Electric Barometer ecosystem. It defines how key evaluation parameters—such as cost ratios, tolerances, and readiness controls—are selected from data, validated under governance rules, and formalized into deterministic policies that can be reused across systems and environments.
10
-
11
- Rather than computing metrics or running evaluations, this repository focuses on decision logic: how parameters are calibrated, how tradeoffs are resolved, and how those decisions are frozen into auditable artifacts. It provides the bridge between metric theory and operational deployment, ensuring that forecast evaluation behavior is consistent, explainable, and governed by explicit intent rather than ad-hoc configuration.
12
-
13
- ---
14
-
15
- ## Role in the Electric Barometer Ecosystem
16
-
17
- `eb-optimization` defines the parameter selection, calibration, and governance logic used throughout the Electric Barometer ecosystem. It is responsible for determining how key operational parameters—such as cost ratios, tolerance bands, and readiness controls—are selected from data in a disciplined, reproducible, and decision-aware manner.
18
-
19
- This repository focuses exclusively on optimization mechanics and policy formation. It does not define metric primitives, perform evaluation orchestration, manage model interfaces, or execute runtime decision logic. Those responsibilities are handled by adjacent layers in the ecosystem that compute metrics, evaluate forecasts, or apply frozen policies in production workflows.
20
-
21
- By separating parameter selection and governance from metric semantics and execution concerns, eb-optimization provides a stable optimization layer that enables consistent calibration, transparent decision rules, and auditable policy artifacts across heterogeneous forecasting and operational contexts.
22
-
23
- ---
24
-
25
- ## Installation
26
-
27
- `eb-optimization` is distributed as a standard Python package.
28
-
29
- ```bash
30
- pip install eb-optimization
31
- ```
32
-
33
- ---
34
-
35
- ## Core Concepts
36
-
37
- - **Parameter governance** — Operational parameters (e.g., cost ratios, tolerances) should be selected through explicit, reproducible rules rather than ad-hoc tuning or implicit defaults.
38
- - **Search over candidate spaces** — Optimization is framed as deterministic search over bounded, interpretable candidate sets, enabling transparent tradeoffs and stable outcomes.
39
- - **Cost balance calibration** — Asymmetric operational costs can be balanced by selecting parameters that equalize or appropriately trade off opposing risk exposures.
40
- - **Tolerance selection from residuals** — Acceptable error bands can be learned directly from historical performance, reflecting empirical system behavior rather than arbitrary thresholds.
41
- - **Policy separation** — Calibration logic is separated from frozen policy artifacts so that parameter selection is auditable, versioned, and safely applied in downstream systems.
42
- - **Decision-aligned optimization** — Optimization is evaluated by operational interpretability and governance fitness, not by abstract numerical optimality alone.
43
-
44
- ---
45
-
46
- ## Minimal Example
47
-
48
- The example below illustrates a typical optimization workflow using `eb-optimization`: calibrating an operational parameter from historical data and applying it via a frozen policy.
49
-
50
- ```python
51
- import numpy as np
52
- from eb_optimization.policies import (
53
- CostRatioPolicy,
54
- apply_cost_ratio_policy,
55
- )
56
-
57
- # Historical actuals and forecasts
58
- y_true = np.array([10, 12, 15, 20])
59
- y_pred = np.array([9, 14, 18, 17])
60
-
61
- # Define a frozen cost-ratio policy
62
- policy = CostRatioPolicy(
63
- R_grid=(0.5, 1.0, 2.0, 3.0),
64
- co=1.0,
65
- )
66
-
67
- # Estimate a global cost ratio R
68
- R, diagnostics = apply_cost_ratio_policy(
69
- y_true=y_true,
70
- y_pred=y_pred,
71
- policy=policy,
72
- )
73
-
74
- print(R)
75
- ```
76
-
77
- ---
78
-
79
- ## License
80
-
81
- BSD 3-Clause License.
1
+ # Electric Barometer · Optimization (`eb-optimization`)
2
+
3
+ [![CI](https://github.com/Economistician/eb-optimization/actions/workflows/ci.yml/badge.svg)](https://github.com/Economistician/eb-optimization/actions/workflows/ci.yml)
4
+ ![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)
5
+ ![Python Versions](https://img.shields.io/pypi/pyversions/eb-optimization)
6
+ ![PyPI](https://img.shields.io/pypi/v/eb-optimization)
7
+
8
+ Decision and policy layer for the Electric Barometer ecosystem, responsible for tuning, calibration, and governed parameter selection.
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ This repository contains the optimization, tuning, and policy governance layer of the Electric Barometer ecosystem. It defines how key evaluation parameters—such as cost ratios, tolerances, and readiness controls—are selected from data, validated under governance rules, and formalized into deterministic policies that can be reused across systems and environments.
15
+
16
+ Rather than computing metrics or running evaluations, this repository focuses on decision logic: how parameters are calibrated, how tradeoffs are resolved, and how those decisions are frozen into auditable artifacts. It provides the bridge between metric theory and operational deployment, ensuring that forecast evaluation behavior is consistent, explainable, and governed by explicit intent rather than ad-hoc configuration.
17
+
18
+ ---
19
+
20
+ ## Role in the Electric Barometer Ecosystem
21
+
22
+ `eb-optimization` defines the parameter selection, calibration, and governance logic used throughout the Electric Barometer ecosystem. It is responsible for determining how key operational parameters—such as cost ratios, tolerance bands, and readiness controls—are selected from data in a disciplined, reproducible, and decision-aware manner.
23
+
24
+ This repository focuses exclusively on optimization mechanics and policy formation. It does not define metric primitives, perform evaluation orchestration, manage model interfaces, or execute runtime decision logic. Those responsibilities are handled by adjacent layers in the ecosystem that compute metrics, evaluate forecasts, or apply frozen policies in production workflows.
25
+
26
+ By separating parameter selection and governance from metric semantics and execution concerns, eb-optimization provides a stable optimization layer that enables consistent calibration, transparent decision rules, and auditable policy artifacts across heterogeneous forecasting and operational contexts.
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ `eb-optimization` is distributed as a standard Python package.
33
+
34
+ ```bash
35
+ pip install eb-optimization
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Core Concepts
41
+
42
+ - **Parameter governance** — Operational parameters (e.g., cost ratios, tolerances) should be selected through explicit, reproducible rules rather than ad-hoc tuning or implicit defaults.
43
+ - **Search over candidate spaces** — Optimization is framed as deterministic search over bounded, interpretable candidate sets, enabling transparent tradeoffs and stable outcomes.
44
+ - **Cost balance calibration** — Asymmetric operational costs can be balanced by selecting parameters that equalize or appropriately trade off opposing risk exposures.
45
+ - **Tolerance selection from residuals** — Acceptable error bands can be learned directly from historical performance, reflecting empirical system behavior rather than arbitrary thresholds.
46
+ - **Policy separation** — Calibration logic is separated from frozen policy artifacts so that parameter selection is auditable, versioned, and safely applied in downstream systems.
47
+ - **Decision-aligned optimization** — Optimization is evaluated by operational interpretability and governance fitness, not by abstract numerical optimality alone.
48
+
49
+ ---
50
+
51
+ ## Minimal Example
52
+
53
+ The example below illustrates a typical optimization workflow using `eb-optimization`: calibrating an operational parameter from historical data and applying it via a frozen policy.
54
+
55
+ ```python
56
+ import numpy as np
57
+ from eb_optimization.policies import (
58
+ CostRatioPolicy,
59
+ apply_cost_ratio_policy,
60
+ )
61
+
62
+ # Historical actuals and forecasts
63
+ y_true = np.array([10, 12, 15, 20])
64
+ y_pred = np.array([9, 14, 18, 17])
65
+
66
+ # Define a frozen cost-ratio policy
67
+ policy = CostRatioPolicy(
68
+ R_grid=(0.5, 1.0, 2.0, 3.0),
69
+ co=1.0,
70
+ )
71
+
72
+ # Estimate a global cost ratio R
73
+ R, diagnostics = apply_cost_ratio_policy(
74
+ y_true=y_true,
75
+ y_pred=y_pred,
76
+ policy=policy,
77
+ )
78
+
79
+ print(R)
80
+ ```
81
+
82
+ ---
83
+
84
+ ## License
85
+
86
+ BSD 3-Clause License.
82
87
  © 2025 Kyle Corrie.