retrainopt 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.
- retrainopt-0.2.0/CHANGELOG.md +37 -0
- retrainopt-0.2.0/CITATION.cff +22 -0
- retrainopt-0.2.0/LICENSE +184 -0
- retrainopt-0.2.0/MANIFEST.in +13 -0
- retrainopt-0.2.0/PKG-INFO +134 -0
- retrainopt-0.2.0/PUBLISHING.md +83 -0
- retrainopt-0.2.0/README.md +102 -0
- retrainopt-0.2.0/RELEASE_CHECKLIST.md +40 -0
- retrainopt-0.2.0/docs/algorithms.md +109 -0
- retrainopt-0.2.0/docs/api.md +37 -0
- retrainopt-0.2.0/docs/conf.py +21 -0
- retrainopt-0.2.0/docs/development.md +118 -0
- retrainopt-0.2.0/docs/evaluation.md +101 -0
- retrainopt-0.2.0/docs/index.md +24 -0
- retrainopt-0.2.0/docs/integrations.md +63 -0
- retrainopt-0.2.0/docs/migration.md +30 -0
- retrainopt-0.2.0/docs/quickstart.md +64 -0
- retrainopt-0.2.0/examples/botorch_timeline.py +28 -0
- retrainopt-0.2.0/examples/minimal_array_timeline.py +46 -0
- retrainopt-0.2.0/examples/sklearn_timeline.py +21 -0
- retrainopt-0.2.0/examples/torch_timeline.py +26 -0
- retrainopt-0.2.0/examples/verify_exact_against_bruteforce.py +87 -0
- retrainopt-0.2.0/pyproject.toml +77 -0
- retrainopt-0.2.0/scripts/build_release.py +61 -0
- retrainopt-0.2.0/scripts/check_repro_compat.py +113 -0
- retrainopt-0.2.0/scripts/installed_smoke.py +60 -0
- retrainopt-0.2.0/scripts/verify_index.py +31 -0
- retrainopt-0.2.0/setup.cfg +4 -0
- retrainopt-0.2.0/setup.py +4 -0
- retrainopt-0.2.0/src/retrainopt/__init__.py +31 -0
- retrainopt-0.2.0/src/retrainopt/__main__.py +8 -0
- retrainopt-0.2.0/src/retrainopt/adapters/__init__.py +13 -0
- retrainopt-0.2.0/src/retrainopt/adapters/model.py +216 -0
- retrainopt-0.2.0/src/retrainopt/adapters/timeline.py +166 -0
- retrainopt-0.2.0/src/retrainopt/cli.py +130 -0
- retrainopt-0.2.0/src/retrainopt/config.py +106 -0
- retrainopt-0.2.0/src/retrainopt/core/__init__.py +20 -0
- retrainopt-0.2.0/src/retrainopt/core/acquisition.py +106 -0
- retrainopt-0.2.0/src/retrainopt/core/bayes_backends.py +282 -0
- retrainopt-0.2.0/src/retrainopt/core/costs.py +14 -0
- retrainopt-0.2.0/src/retrainopt/core/dp.py +208 -0
- retrainopt-0.2.0/src/retrainopt/core/surrogate.py +273 -0
- retrainopt-0.2.0/src/retrainopt/evaluation.py +170 -0
- retrainopt-0.2.0/src/retrainopt/interfaces.py +79 -0
- retrainopt-0.2.0/src/retrainopt/planner.py +677 -0
- retrainopt-0.2.0/src/retrainopt/py.typed +0 -0
- retrainopt-0.2.0/src/retrainopt/types.py +102 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/PKG-INFO +134 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/SOURCES.txt +58 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/dependency_links.txt +1 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/entry_points.txt +2 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/requires.txt +11 -0
- retrainopt-0.2.0/src/retrainopt.egg-info/top_level.txt +1 -0
- retrainopt-0.2.0/tests/test_algorithm_contracts.py +334 -0
- retrainopt-0.2.0/tests/test_boundary_contracts.py +245 -0
- retrainopt-0.2.0/tests/test_retrainopt_botorch.py +112 -0
- retrainopt-0.2.0/tests/test_retrainopt_example.py +50 -0
- retrainopt-0.2.0/tests/test_retrainopt_planner.py +733 -0
- retrainopt-0.2.0/tests/test_retrainopt_smoke.py +94 -0
- retrainopt-0.2.0/uv.lock +2493 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — 2026-10-14
|
|
4
|
+
|
|
5
|
+
### Correctness
|
|
6
|
+
|
|
7
|
+
- Apply acquisition functions to complete weighted per-stage costs. Combine
|
|
8
|
+
independent training/loss posterior variances with squared weights.
|
|
9
|
+
- Use zero uncertainty for measured costs, one observed stage-cost incumbent
|
|
10
|
+
for EI/PI, and the paper's zero-standard-deviation EI/PI convention.
|
|
11
|
+
- Honor an explicit initial-loss baseline even with a nonempty first block.
|
|
12
|
+
- Validate configuration, timeline inputs and evaluated costs instead of
|
|
13
|
+
silently substituting defaults for invalid values.
|
|
14
|
+
|
|
15
|
+
### Public API
|
|
16
|
+
|
|
17
|
+
- Add evaluator injection through `EvaluationProvider` and publicly expose
|
|
18
|
+
`CandidateEvaluation`.
|
|
19
|
+
- Freeze planner configuration and isolate planner configuration snapshots.
|
|
20
|
+
- Add `PlanResult.weighted_loss_cost`; preserve the raw `loss_cost` field.
|
|
21
|
+
Serialized results use schema version 2 and versioned metadata.
|
|
22
|
+
|
|
23
|
+
### Distribution
|
|
24
|
+
|
|
25
|
+
- Add an algorithm guide, public API reference, migration notes and runnable
|
|
26
|
+
documentation, plus optional scikit-learn, PyTorch and BoTorch examples.
|
|
27
|
+
- Document source, installed-package and documentation validation, and a
|
|
28
|
+
staged release procedure.
|
|
29
|
+
|
|
30
|
+
Approximate plans can change under the corrected acquisition semantics.
|
|
31
|
+
The frozen paper implementation and canonical experiment pin are unchanged.
|
|
32
|
+
|
|
33
|
+
## 0.1.0 (unpublished)
|
|
34
|
+
|
|
35
|
+
Initial standalone library with exact and approximate planning, timeline/model
|
|
36
|
+
adapters, and a binary-timeline CLI.
|
|
37
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "Please cite RetrainOpt and the paper describing its offline planning algorithms."
|
|
3
|
+
type: software
|
|
4
|
+
title: RetrainOpt
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
authors:
|
|
7
|
+
- family-names: Yang
|
|
8
|
+
given-names: Jun
|
|
9
|
+
repository-code: "https://github.com/yangjun42/retrainopt"
|
|
10
|
+
license: Apache-2.0
|
|
11
|
+
preferred-citation:
|
|
12
|
+
type: conference-paper
|
|
13
|
+
title: "Automated Retraining for Cost-Optimal ML"
|
|
14
|
+
authors:
|
|
15
|
+
- family-names: Yang
|
|
16
|
+
given-names: Jun
|
|
17
|
+
- family-names: Mathioudakis
|
|
18
|
+
given-names: Michael
|
|
19
|
+
year: 2026
|
|
20
|
+
conference:
|
|
21
|
+
name: "ECML PKDD 2026"
|
|
22
|
+
|
retrainopt-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
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, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and
|
|
27
|
+
configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object
|
|
31
|
+
code, generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
46
|
+
version of the Work and any modifications or additions to that Work or
|
|
47
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
48
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
49
|
+
Entity authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal, or
|
|
51
|
+
written communication sent to the Licensor or its representatives, including
|
|
52
|
+
but not limited to communication on electronic mailing lists, source code
|
|
53
|
+
control systems, and issue tracking systems that are managed by, or on behalf
|
|
54
|
+
of, the Licensor for the purpose of discussing and improving the Work, but
|
|
55
|
+
excluding communication that is conspicuously marked or otherwise designated in
|
|
56
|
+
writing by the copyright owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
70
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
71
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
72
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
73
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
74
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
75
|
+
their Contribution(s) alone or by combination of their Contribution(s) with the
|
|
76
|
+
Work to which such Contribution(s) was submitted. If You institute patent
|
|
77
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
78
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
80
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
81
|
+
the date such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
88
|
+
of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
95
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
96
|
+
part of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents
|
|
106
|
+
of the NOTICE file are for informational purposes only and do not modify the
|
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
|
110
|
+
modifying the License.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
113
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
114
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
115
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
116
|
+
complies with the conditions stated in this License.
|
|
117
|
+
|
|
118
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
119
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
120
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
121
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
122
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
123
|
+
executed with Licensor regarding such Contributions.
|
|
124
|
+
|
|
125
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
126
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
127
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
128
|
+
reproducing the content of the NOTICE file.
|
|
129
|
+
|
|
130
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
131
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
132
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
133
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
134
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
137
|
+
associated with Your exercise of permissions under this License.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
140
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
141
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
142
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
143
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
144
|
+
character arising as a result of this License or out of the use or inability to
|
|
145
|
+
use the Work (including but not limited to damages for loss of goodwill, work
|
|
146
|
+
stoppage, computer failure or malfunction, or any and all other commercial
|
|
147
|
+
damages or losses), even if such Contributor has been advised of the
|
|
148
|
+
possibility of such damages.
|
|
149
|
+
|
|
150
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
151
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
152
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
153
|
+
and/or rights consistent with this License. However, in accepting such
|
|
154
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
155
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
156
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
157
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
158
|
+
accepting any such warranty or additional liability.
|
|
159
|
+
|
|
160
|
+
END OF TERMS AND CONDITIONS
|
|
161
|
+
|
|
162
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
163
|
+
|
|
164
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
165
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
166
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
167
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
168
|
+
recommend that a file or class name and description of purpose be included on
|
|
169
|
+
the same "printed page" as the copyright notice for easier identification
|
|
170
|
+
within third-party archives.
|
|
171
|
+
|
|
172
|
+
Copyright [yyyy] [name of copyright owner]
|
|
173
|
+
|
|
174
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
175
|
+
you may not use this file except in compliance with the License.
|
|
176
|
+
You may obtain a copy of the License at
|
|
177
|
+
|
|
178
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
179
|
+
|
|
180
|
+
Unless required by applicable law or agreed to in writing, software
|
|
181
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
182
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
183
|
+
See the License for the specific language governing permissions and
|
|
184
|
+
limitations under the License.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include CHANGELOG.md
|
|
4
|
+
include CITATION.cff
|
|
5
|
+
include PUBLISHING.md
|
|
6
|
+
include RELEASE_CHECKLIST.md
|
|
7
|
+
recursive-include docs *.md *.py
|
|
8
|
+
include uv.lock
|
|
9
|
+
recursive-include scripts *.py
|
|
10
|
+
recursive-include examples *.py
|
|
11
|
+
recursive-include tests *.py
|
|
12
|
+
global-exclude __pycache__
|
|
13
|
+
global-exclude *.py[cod]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: retrainopt
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: RetrainOpt - Cost-aware retraining planning
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/yangjun42/retrainopt
|
|
7
|
+
Project-URL: Repository, https://github.com/yangjun42/retrainopt
|
|
8
|
+
Project-URL: Issues, https://github.com/yangjun42/retrainopt/issues
|
|
9
|
+
Project-URL: Documentation, https://yangjun42.github.io/retrainopt/
|
|
10
|
+
Keywords: retraining,model-maintenance,cost-aware,time-sliced-datasets
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Provides-Extra: sklearn
|
|
24
|
+
Requires-Dist: scikit-learn>=1.4.2; extra == "sklearn"
|
|
25
|
+
Provides-Extra: torch
|
|
26
|
+
Requires-Dist: torch>=2.4; extra == "torch"
|
|
27
|
+
Provides-Extra: botorch
|
|
28
|
+
Requires-Dist: botorch>=0.16.1; extra == "botorch"
|
|
29
|
+
Requires-Dist: gpytorch; extra == "botorch"
|
|
30
|
+
Requires-Dist: torch>=2.4; extra == "botorch"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# RetrainOpt
|
|
34
|
+
|
|
35
|
+
Offline planning for **when to retrain a model and how much data to use**,
|
|
36
|
+
balancing training cost and predictive loss.
|
|
37
|
+
|
|
38
|
+
RetrainOpt provides exact dynamic programming and surrogate-guided approximate
|
|
39
|
+
search over a supplied timeline. It implements the offline core of
|
|
40
|
+
*Automated Retraining for Cost-Optimal ML* (Jun Yang and Michael Mathioudakis,
|
|
41
|
+
2026). It is an algorithm library: deployment, online drift detection and
|
|
42
|
+
experiment orchestration are outside its scope.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
Python 3.10 or later. The core has no mandatory third-party runtime dependencies.
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
python -m pip install retrainopt
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Optional integrations:
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
python -m pip install 'retrainopt[sklearn]'
|
|
56
|
+
python -m pip install 'retrainopt[torch]'
|
|
57
|
+
python -m pip install 'retrainopt[botorch]'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from retrainopt import PlannerConfig, RetrainingPlanner
|
|
64
|
+
from retrainopt.adapters import ArrayTimelineAdapter, PrototypeModelAdapter
|
|
65
|
+
|
|
66
|
+
timeline = ArrayTimelineAdapter(
|
|
67
|
+
train_blocks=[
|
|
68
|
+
[((0.0,), 0), ((1.0,), 1)],
|
|
69
|
+
[((0.0,), 1), ((1.0,), 0)],
|
|
70
|
+
],
|
|
71
|
+
eval_blocks=[
|
|
72
|
+
[((0.1,), 0), ((0.9,), 1)],
|
|
73
|
+
[((0.1,), 1), ((0.9,), 0)],
|
|
74
|
+
],
|
|
75
|
+
)
|
|
76
|
+
config = PlannerConfig(
|
|
77
|
+
n_choices=(1.0,), # Full block; integer 1 would mean one sample.
|
|
78
|
+
initial_loss=1.0, # Explicit initial baseline; no bootstrap fit.
|
|
79
|
+
time_cost_weight=0.0, # Ignore wall-clock noise in this small example.
|
|
80
|
+
loss_cost_weight=1.0,
|
|
81
|
+
)
|
|
82
|
+
result = RetrainingPlanner(timeline, PrototypeModelAdapter(), config).plan("exact")
|
|
83
|
+
print([decision.action.value for decision in result.decisions])
|
|
84
|
+
print(result.total_cost)
|
|
85
|
+
# ['retrain', 'retrain']
|
|
86
|
+
# 0.0
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each train block is the complete available dataset at that time; blocks are
|
|
90
|
+
not accumulated automatically. The planner can inspect the entire timeline,
|
|
91
|
+
including evaluation blocks. These are optimization inputs, so the selected
|
|
92
|
+
plan's cost is not an independent future-performance estimate.
|
|
93
|
+
|
|
94
|
+
## Choosing a method
|
|
95
|
+
|
|
96
|
+
| Method | What it does |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `exact` | Measures every configured candidate and finds the minimum-cost schedule over that finite candidate set. |
|
|
99
|
+
| `bayes`, `lightweight` backend | Uses a dependency-free nearest-neighbor heuristic to select candidates. |
|
|
100
|
+
| `bayes`, `botorch` backend | Uses optional Gaussian-process surrogates for acquisition-guided search. |
|
|
101
|
+
|
|
102
|
+
For `bayes`, `estimated_total_cost` is the surrogate estimate, while
|
|
103
|
+
`total_cost` is measured for the selected schedule. Approximate search does not
|
|
104
|
+
guarantee the global optimum. Sequence selection can train more models than
|
|
105
|
+
`bayes_candidates_per_iteration`, which is a minimum target, not a hard budget.
|
|
106
|
+
|
|
107
|
+
`PlanResult.training_cost` is weighted training cost, `loss_cost` is raw summed
|
|
108
|
+
loss, and `weighted_loss_cost` is the loss contribution to `total_cost`.
|
|
109
|
+
Planning's exploratory fits are not part of the selected schedule's objective.
|
|
110
|
+
|
|
111
|
+
## Documentation and examples
|
|
112
|
+
|
|
113
|
+
- [Quick start](https://yangjun42.github.io/retrainopt/quickstart.html), [algorithm semantics](https://yangjun42.github.io/retrainopt/algorithms.html)
|
|
114
|
+
- [Initial models, costs and evaluator injection](https://yangjun42.github.io/retrainopt/evaluation.html)
|
|
115
|
+
- [Optional adapters and CLI](https://yangjun42.github.io/retrainopt/integrations.html), [API](https://yangjun42.github.io/retrainopt/api.html)
|
|
116
|
+
- [Migration from 0.1](https://yangjun42.github.io/retrainopt/migration.html), [changelog](https://github.com/yangjun42/retrainopt/blob/main/CHANGELOG.md)
|
|
117
|
+
- [Development and validation](https://yangjun42.github.io/retrainopt/development.html), [publishing](https://github.com/yangjun42/retrainopt/blob/main/PUBLISHING.md)
|
|
118
|
+
|
|
119
|
+
```shell
|
|
120
|
+
python examples/minimal_array_timeline.py
|
|
121
|
+
python examples/verify_exact_against_bruteforce.py
|
|
122
|
+
# After installing the corresponding extra:
|
|
123
|
+
python examples/sklearn_timeline.py
|
|
124
|
+
python examples/torch_timeline.py
|
|
125
|
+
python examples/botorch_timeline.py
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Version 0.2 corrects acquisition composition and tightens public contracts.
|
|
129
|
+
It does not replace the paper's frozen code or the separate canonical
|
|
130
|
+
`retrainopt-paper-repro` pin `ecml-pkdd-2026-camera-ready-retrainopt`.
|
|
131
|
+
Use [CITATION.cff](https://github.com/yangjun42/retrainopt/blob/main/CITATION.cff) to cite this software and the paper.
|
|
132
|
+
|
|
133
|
+
Apache-2.0 licensed. Source and issues:
|
|
134
|
+
[github.com/yangjun42/retrainopt](https://github.com/yangjun42/retrainopt).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Publishing RetrainOpt
|
|
2
|
+
|
|
3
|
+
Publishing uses GitHub Actions and PyPI Trusted Publishing (OIDC). A local
|
|
4
|
+
build or green pull request does not upload a release. The publishing workflow
|
|
5
|
+
runs only on `v*` tags, checks that the tag exactly matches `pyproject.toml`, and
|
|
6
|
+
validates that tagged revision before uploading its artifacts.
|
|
7
|
+
|
|
8
|
+
## Repository and publisher setup
|
|
9
|
+
|
|
10
|
+
The account owner must configure these external settings before publication:
|
|
11
|
+
|
|
12
|
+
1. On TestPyPI and PyPI, configure the project `retrainopt` (or a pending
|
|
13
|
+
publisher for a new project) with repository `yangjun42/retrainopt`, workflow
|
|
14
|
+
`publish.yml`, and GitHub environment `testpypi` or `pypi`, respectively.
|
|
15
|
+
2. Create the corresponding GitHub environments and configure their protection
|
|
16
|
+
rules. Restrict production publishing to reviewed release tags.
|
|
17
|
+
3. Enable GitHub Pages with GitHub Actions as its source. Documentation deploys
|
|
18
|
+
through the `github-pages` environment.
|
|
19
|
+
4. Confirm the workflows are enabled and that the publisher names, repository
|
|
20
|
+
ownership and environment names match exactly.
|
|
21
|
+
|
|
22
|
+
The checked-in workflow expects this setup; it does not create publisher
|
|
23
|
+
accounts. It does not require a `PYPI_API_TOKEN` secret. Do not replace the
|
|
24
|
+
Trusted Publishing configuration with an unreviewed manual upload workaround.
|
|
25
|
+
|
|
26
|
+
## Validate before tagging
|
|
27
|
+
|
|
28
|
+
Use the locked groups and commands in [Development](docs/development.md).
|
|
29
|
+
The release checks cover:
|
|
30
|
+
|
|
31
|
+
- core tests and optional sklearn/Torch/BoTorch integrations;
|
|
32
|
+
- exact-vs-exhaustive verification and acquisition regression cases;
|
|
33
|
+
- warning-free HTML and doctest builds;
|
|
34
|
+
- built wheel and source-distribution validation;
|
|
35
|
+
- installation and smoke execution outside the source checkout.
|
|
36
|
+
|
|
37
|
+
Review [CHANGELOG.md](CHANGELOG.md), migration notes and `CITATION.cff`. Version
|
|
38
|
+
metadata must match the intended release. Keep the paper's frozen reproduction
|
|
39
|
+
pin unchanged.
|
|
40
|
+
|
|
41
|
+
## Release candidate
|
|
42
|
+
|
|
43
|
+
For a candidate such as `0.2.0rc1`, set the package version to `0.2.0rc1` and use
|
|
44
|
+
the corresponding tag `v0.2.0rc1`. After the reviewed commit is ready:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
git tag -a v0.2.0rc1 -m 'RetrainOpt 0.2.0rc1'
|
|
48
|
+
git push origin v0.2.0rc1
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The workflow routes `rc` versions to **TestPyPI** using environment `testpypi`.
|
|
52
|
+
It reuses the validated distributions, verifies their checksums, uploads them,
|
|
53
|
+
then tests an anonymous installation from that index. Only after verification
|
|
54
|
+
succeeds does it create the GitHub prerelease with artifacts and checksums.
|
|
55
|
+
|
|
56
|
+
This core-only manual verification is useful after the workflow completes:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
python -m pip install --no-deps --index-url https://test.pypi.org/simple/ 'retrainopt==0.2.0rc1'
|
|
60
|
+
python -c 'import retrainopt; print(retrainopt.__version__)'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use a clean environment and run outside the source checkout. TestPyPI is for
|
|
64
|
+
the candidate package; optional integration dependencies should come from
|
|
65
|
+
their normal package indexes through the locked validation environment.
|
|
66
|
+
|
|
67
|
+
## Final release
|
|
68
|
+
|
|
69
|
+
After candidate verification, update the package and citation version to
|
|
70
|
+
`0.2.0`, refresh the lock as needed, and merge the reviewed release changes to
|
|
71
|
+
`main`. Create and push `v0.2.0` from that revision. The workflow requires a
|
|
72
|
+
stable release tag to be an ancestor of `origin/main`.
|
|
73
|
+
|
|
74
|
+
Stable versions route to **PyPI** using environment `pypi`. Upload, anonymous
|
|
75
|
+
index-install verification, and GitHub release creation follow the same order
|
|
76
|
+
as the candidate. The documentation workflow deploys `main` on a push or an
|
|
77
|
+
explicit dispatch targeting `main`; release uploads do not independently
|
|
78
|
+
publish documentation.
|
|
79
|
+
|
|
80
|
+
If publisher configuration is missing or a check fails, preserve the failed
|
|
81
|
+
run and artifacts and fix the cause. Report publication as incomplete. PyPI
|
|
82
|
+
versions are not overwriteable; use a new candidate version for changed
|
|
83
|
+
candidate artifacts rather than moving an already published tag.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# RetrainOpt
|
|
2
|
+
|
|
3
|
+
Offline planning for **when to retrain a model and how much data to use**,
|
|
4
|
+
balancing training cost and predictive loss.
|
|
5
|
+
|
|
6
|
+
RetrainOpt provides exact dynamic programming and surrogate-guided approximate
|
|
7
|
+
search over a supplied timeline. It implements the offline core of
|
|
8
|
+
*Automated Retraining for Cost-Optimal ML* (Jun Yang and Michael Mathioudakis,
|
|
9
|
+
2026). It is an algorithm library: deployment, online drift detection and
|
|
10
|
+
experiment orchestration are outside its scope.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Python 3.10 or later. The core has no mandatory third-party runtime dependencies.
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
python -m pip install retrainopt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Optional integrations:
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
python -m pip install 'retrainopt[sklearn]'
|
|
24
|
+
python -m pip install 'retrainopt[torch]'
|
|
25
|
+
python -m pip install 'retrainopt[botorch]'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from retrainopt import PlannerConfig, RetrainingPlanner
|
|
32
|
+
from retrainopt.adapters import ArrayTimelineAdapter, PrototypeModelAdapter
|
|
33
|
+
|
|
34
|
+
timeline = ArrayTimelineAdapter(
|
|
35
|
+
train_blocks=[
|
|
36
|
+
[((0.0,), 0), ((1.0,), 1)],
|
|
37
|
+
[((0.0,), 1), ((1.0,), 0)],
|
|
38
|
+
],
|
|
39
|
+
eval_blocks=[
|
|
40
|
+
[((0.1,), 0), ((0.9,), 1)],
|
|
41
|
+
[((0.1,), 1), ((0.9,), 0)],
|
|
42
|
+
],
|
|
43
|
+
)
|
|
44
|
+
config = PlannerConfig(
|
|
45
|
+
n_choices=(1.0,), # Full block; integer 1 would mean one sample.
|
|
46
|
+
initial_loss=1.0, # Explicit initial baseline; no bootstrap fit.
|
|
47
|
+
time_cost_weight=0.0, # Ignore wall-clock noise in this small example.
|
|
48
|
+
loss_cost_weight=1.0,
|
|
49
|
+
)
|
|
50
|
+
result = RetrainingPlanner(timeline, PrototypeModelAdapter(), config).plan("exact")
|
|
51
|
+
print([decision.action.value for decision in result.decisions])
|
|
52
|
+
print(result.total_cost)
|
|
53
|
+
# ['retrain', 'retrain']
|
|
54
|
+
# 0.0
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Each train block is the complete available dataset at that time; blocks are
|
|
58
|
+
not accumulated automatically. The planner can inspect the entire timeline,
|
|
59
|
+
including evaluation blocks. These are optimization inputs, so the selected
|
|
60
|
+
plan's cost is not an independent future-performance estimate.
|
|
61
|
+
|
|
62
|
+
## Choosing a method
|
|
63
|
+
|
|
64
|
+
| Method | What it does |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `exact` | Measures every configured candidate and finds the minimum-cost schedule over that finite candidate set. |
|
|
67
|
+
| `bayes`, `lightweight` backend | Uses a dependency-free nearest-neighbor heuristic to select candidates. |
|
|
68
|
+
| `bayes`, `botorch` backend | Uses optional Gaussian-process surrogates for acquisition-guided search. |
|
|
69
|
+
|
|
70
|
+
For `bayes`, `estimated_total_cost` is the surrogate estimate, while
|
|
71
|
+
`total_cost` is measured for the selected schedule. Approximate search does not
|
|
72
|
+
guarantee the global optimum. Sequence selection can train more models than
|
|
73
|
+
`bayes_candidates_per_iteration`, which is a minimum target, not a hard budget.
|
|
74
|
+
|
|
75
|
+
`PlanResult.training_cost` is weighted training cost, `loss_cost` is raw summed
|
|
76
|
+
loss, and `weighted_loss_cost` is the loss contribution to `total_cost`.
|
|
77
|
+
Planning's exploratory fits are not part of the selected schedule's objective.
|
|
78
|
+
|
|
79
|
+
## Documentation and examples
|
|
80
|
+
|
|
81
|
+
- [Quick start](https://yangjun42.github.io/retrainopt/quickstart.html), [algorithm semantics](https://yangjun42.github.io/retrainopt/algorithms.html)
|
|
82
|
+
- [Initial models, costs and evaluator injection](https://yangjun42.github.io/retrainopt/evaluation.html)
|
|
83
|
+
- [Optional adapters and CLI](https://yangjun42.github.io/retrainopt/integrations.html), [API](https://yangjun42.github.io/retrainopt/api.html)
|
|
84
|
+
- [Migration from 0.1](https://yangjun42.github.io/retrainopt/migration.html), [changelog](https://github.com/yangjun42/retrainopt/blob/main/CHANGELOG.md)
|
|
85
|
+
- [Development and validation](https://yangjun42.github.io/retrainopt/development.html), [publishing](https://github.com/yangjun42/retrainopt/blob/main/PUBLISHING.md)
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
python examples/minimal_array_timeline.py
|
|
89
|
+
python examples/verify_exact_against_bruteforce.py
|
|
90
|
+
# After installing the corresponding extra:
|
|
91
|
+
python examples/sklearn_timeline.py
|
|
92
|
+
python examples/torch_timeline.py
|
|
93
|
+
python examples/botorch_timeline.py
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Version 0.2 corrects acquisition composition and tightens public contracts.
|
|
97
|
+
It does not replace the paper's frozen code or the separate canonical
|
|
98
|
+
`retrainopt-paper-repro` pin `ecml-pkdd-2026-camera-ready-retrainopt`.
|
|
99
|
+
Use [CITATION.cff](https://github.com/yangjun42/retrainopt/blob/main/CITATION.cff) to cite this software and the paper.
|
|
100
|
+
|
|
101
|
+
Apache-2.0 licensed. Source and issues:
|
|
102
|
+
[github.com/yangjun42/retrainopt](https://github.com/yangjun42/retrainopt).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Release checklist
|
|
2
|
+
|
|
3
|
+
## Source and behavior
|
|
4
|
+
|
|
5
|
+
- [ ] Release changes reviewed; working tree and tag identify the intended revision.
|
|
6
|
+
- [ ] Package version, citation version and tag agree.
|
|
7
|
+
- [ ] Changelog and migration notes describe acquisition and initial-model changes.
|
|
8
|
+
- [ ] Exact DP passes independent exhaustive checks on small fixtures.
|
|
9
|
+
- [ ] Whole-stage acquisition, weighted variance, observed entries and zero-variance EI/PI pass regression checks.
|
|
10
|
+
- [ ] Evaluator, configuration, data and cost contracts pass tests.
|
|
11
|
+
- [ ] Paper reproduction tag/pin and frozen artifacts remain unchanged.
|
|
12
|
+
|
|
13
|
+
## Distribution and documentation
|
|
14
|
+
|
|
15
|
+
- [ ] Locked test/build/docs groups resolve and validate.
|
|
16
|
+
- [ ] Minimal example and optional sklearn/Torch/BoTorch examples pass.
|
|
17
|
+
- [ ] Sphinx HTML and doctests build without warnings.
|
|
18
|
+
- [ ] Wheel and sdist build, metadata checks pass, and checksums are recorded.
|
|
19
|
+
- [ ] Wheel and sdist-derived installations run outside the source checkout.
|
|
20
|
+
- [ ] Public API, assumptions, cost accounting and limitations are documented.
|
|
21
|
+
|
|
22
|
+
## External configuration
|
|
23
|
+
|
|
24
|
+
- [ ] TestPyPI Trusted Publisher matches `publish.yml` and `testpypi`.
|
|
25
|
+
- [ ] PyPI Trusted Publisher matches `publish.yml` and `pypi`.
|
|
26
|
+
- [ ] GitHub environments and protection rules are configured.
|
|
27
|
+
- [ ] GitHub Pages uses Actions and its deployment environment is ready.
|
|
28
|
+
|
|
29
|
+
## Publication
|
|
30
|
+
|
|
31
|
+
- [ ] Candidate tag exactly matches the `rc` package version.
|
|
32
|
+
- [ ] Tagged validation and TestPyPI upload succeed.
|
|
33
|
+
- [ ] Anonymous TestPyPI install succeeds; GitHub prerelease contains verified artifacts/checksums.
|
|
34
|
+
- [ ] Final version is reviewed on `main`; stable tag matches package version.
|
|
35
|
+
- [ ] PyPI upload and anonymous PyPI installation succeed.
|
|
36
|
+
- [ ] GitHub release contains verified artifacts/checksums and links to migration notes.
|
|
37
|
+
- [ ] Documentation deployment succeeds and shows the intended release.
|
|
38
|
+
|
|
39
|
+
Unchecked publisher/index/deployment steps mean publication is pending, even
|
|
40
|
+
when local validation is complete. See [PUBLISHING.md](PUBLISHING.md).
|