SKSurrogate 0.2.0__tar.gz → 0.3.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.
- sksurrogate-0.2.0/License.txt → sksurrogate-0.3.0/LICENSE +1 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/MANIFEST.in +1 -1
- sksurrogate-0.3.0/PKG-INFO +309 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/DataProcess.py +213 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/NpyProximation.py +21 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/__init__.py +14 -2
- sksurrogate-0.3.0/SKSurrogate/_logutil.py +69 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/aml.py +559 -104
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/deployment.py +2 -2
- sksurrogate-0.3.0/SKSurrogate/design.py +185 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/eoa.py +104 -35
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/inference.py +13 -9
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/mltrace.py +1265 -88
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/modelbundle.py +20 -0
- sksurrogate-0.3.0/SKSurrogate/monitoring.py +1090 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/retraining.py +22 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/sensapprx.py +0 -26
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/structsearch.py +475 -99
- sksurrogate-0.3.0/SKSurrogate.egg-info/PKG-INFO +309 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate.egg-info/SOURCES.txt +56 -2
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate.egg-info/requires.txt +2 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/conf.py +32 -5
- sksurrogate-0.3.0/docs/controlplane.rst +225 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/dataproc.rst +28 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/eoa.rst +13 -7
- sksurrogate-0.3.0/docs/experiment-design.rst +157 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/hilbert.rst +6 -0
- sksurrogate-0.3.0/docs/images/make_stability_contour.py +280 -0
- sksurrogate-0.3.0/docs/images/stability_contour.png +0 -0
- sksurrogate-0.3.0/docs/images/ui-explain-explanations.png +0 -0
- sksurrogate-0.3.0/docs/images/ui-logs.png +0 -0
- sksurrogate-0.3.0/docs/images/ui-project-synthesis.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-01-dashboard.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-02-datasets-inspect.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-03-datasets-validate.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-04-datasets-registered.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-05-features-sensitivity.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-06-features-ranking.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-07-experiments-quickstart.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-08-experiments-result.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-09-bundles-train.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-10-bundles-list.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-11-evaluation.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-12-explain-importance.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-13-explain-intervals.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-14-quality-gate.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-15-registry.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-16-inference.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-17-monitoring.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-18-monitoring-drift.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-19-projects.png +0 -0
- sksurrogate-0.3.0/docs/images/wt-20-design.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/index.rst +17 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/inference.rst +37 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/intro.rst +3 -3
- sksurrogate-0.3.0/docs/mltrace.rst +861 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/modelbundles.rst +40 -0
- sksurrogate-0.3.0/docs/monitoring.rst +243 -0
- sksurrogate-0.3.0/docs/notebooks.rst +56 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/opd.rst +8 -3
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/phase10.rst +3 -3
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/phase9.rst +50 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/release.rst +15 -15
- sksurrogate-0.3.0/docs/research-projects.rst +286 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/sensitivity.rst +24 -2
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/surrogate.rst +45 -4
- sksurrogate-0.3.0/docs/telemetry.rst +286 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/ui-manual.rst +228 -33
- sksurrogate-0.3.0/docs/walkthrough.rst +552 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example01.py +1 -1
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example02.py +5 -2
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example03_mltrace.py +9 -9
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example05_full_classification.py +2 -2
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example06_full_regression.py +2 -2
- sksurrogate-0.3.0/examples/smoke_aml.py +56 -0
- sksurrogate-0.3.0/readme.rst +248 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/requirements.txt +1 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/setup.py +24 -4
- sksurrogate-0.3.0/tests/api_snapshot.py +45 -0
- sksurrogate-0.3.0/tests/test_api_experiments.py +355 -0
- sksurrogate-0.3.0/tests/test_api_explanations.py +554 -0
- sksurrogate-0.3.0/tests/test_api_key_auth.py +223 -0
- sksurrogate-0.3.0/tests/test_api_logs.py +276 -0
- sksurrogate-0.3.0/tests/test_api_safety.py +105 -0
- sksurrogate-0.3.0/tests/test_api_simplification.py +183 -0
- sksurrogate-0.3.0/tests/test_api_synthesis.py +305 -0
- sksurrogate-0.3.0/tests/test_benchmark_archive_readers.py +152 -0
- sksurrogate-0.3.0/tests/test_benchmark_datasets.py +107 -0
- sksurrogate-0.3.0/tests/test_benchmark_design_readiness.py +136 -0
- sksurrogate-0.3.0/tests/test_benchmark_dgps.py +187 -0
- sksurrogate-0.3.0/tests/test_benchmark_methods.py +100 -0
- sksurrogate-0.3.0/tests/test_eoa_aliases.py +98 -0
- sksurrogate-0.3.0/tests/test_eoa_checkpoint.py +94 -0
- sksurrogate-0.3.0/tests/test_logging_telemetry.py +359 -0
- sksurrogate-0.3.0/tests/test_optimized_paths.py +2961 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase1_endpoints.py +323 -2
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase2_endpoints.py +15 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase3_endpoints.py +100 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase4_endpoints.py +21 -8
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase5_endpoints.py +51 -0
- sksurrogate-0.3.0/tests/test_phase6_endpoints.py +432 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/tests/test_phase7_endpoints.py +50 -3
- sksurrogate-0.3.0/tests/test_projects_endpoints.py +1125 -0
- sksurrogate-0.3.0/tests/test_quantile_evaluation.py +64 -0
- sksurrogate-0.3.0/tests/test_real_noise_gp_probe.py +52 -0
- sksurrogate-0.3.0/tests/test_surrogate_diagnostics.py +156 -0
- sksurrogate-0.3.0/tests/test_time_series_evaluation.py +85 -0
- sksurrogate-0.2.0/PKG-INFO +0 -161
- sksurrogate-0.2.0/SKSurrogate/monitoring.py +0 -360
- sksurrogate-0.2.0/SKSurrogate.egg-info/PKG-INFO +0 -161
- sksurrogate-0.2.0/docs/controlplane.rst +0 -85
- sksurrogate-0.2.0/docs/mltrace.rst +0 -425
- sksurrogate-0.2.0/docs/monitoring.rst +0 -142
- sksurrogate-0.2.0/readme.rst +0 -109
- sksurrogate-0.2.0/tests/test_optimized_paths.py +0 -1408
- sksurrogate-0.2.0/tests/test_phase6_endpoints.py +0 -216
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/ci.py +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/execution.py +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate/synthdat.py +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate.egg-info/dependency_links.txt +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate.egg-info/entry_points.txt +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/SKSurrogate.egg-info/top_level.txt +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/Makefile +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/code.rst +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best1.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best10.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best11.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best12.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best2.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best3.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best4.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best5.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best6.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best7.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best8.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/best9.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/correlations.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/funnel.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/lego.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/points.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/points_fit_optm.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/polyreg.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-bundles.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-dashboard.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-datasets.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-evaluation.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-experiments.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-features.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-inference.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-jobs.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-monitoring.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-quality-gates.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-registry.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-retraining.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/ui-settings.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/images/weights.png +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/docs/make.bat +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/benchmark_phase10.py +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/examples/example04_end_to_end.py +0 -0
- {sksurrogate-0.2.0 → sksurrogate-0.3.0}/setup.cfg +0 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SKSurrogate
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Lightweight, maintained, scikit-learn-native surrogate tuner for hyperparameter and AutoML pipeline search; a drop-in replacement for BayesSearchCV.
|
|
5
|
+
Home-page: https://github.com/mghasemi/sksurrogate
|
|
6
|
+
Author: Mehdi Ghasemi
|
|
7
|
+
Author-email: mehdi.ghasemi@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Source, https://github.com/mghasemi/sksurrogate
|
|
10
|
+
Project-URL: Documentation, https://sksurrogate.readthedocs.io/
|
|
11
|
+
Project-URL: Zenodo (software), https://doi.org/10.5281/zenodo.23631823
|
|
12
|
+
Project-URL: Zenodo (benchmark data), https://doi.org/10.5281/zenodo.23629024
|
|
13
|
+
Keywords: hyperparameter optimization,surrogate,scikit-learn,AutoML,Bayesian optimization,trust region,evolutionary optimization,drift detection,Auto Machine Learning,Optimization,Surrogate Optimization,Machine Learning,Regression,Random Search
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.22
|
|
27
|
+
Requires-Dist: scipy>=1.10
|
|
28
|
+
Requires-Dist: pandas
|
|
29
|
+
Requires-Dist: matplotlib
|
|
30
|
+
Requires-Dist: scikit-learn>=1.5
|
|
31
|
+
Requires-Dist: lightgbm>=4.6
|
|
32
|
+
Requires-Dist: xgboost>=2.1
|
|
33
|
+
Requires-Dist: SALib
|
|
34
|
+
Requires-Dist: imbalanced-learn
|
|
35
|
+
Requires-Dist: joblib>=1.2
|
|
36
|
+
Requires-Dist: eli5
|
|
37
|
+
Requires-Dist: skrebate
|
|
38
|
+
Requires-Dist: tqdm>=4.66.3
|
|
39
|
+
Requires-Dist: peewee
|
|
40
|
+
Requires-Dist: category_encoders
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
Requires-Dist: pytest; extra == "test"
|
|
43
|
+
Requires-Dist: pygments; extra == "test"
|
|
44
|
+
Provides-Extra: benchmark
|
|
45
|
+
Requires-Dist: openml<0.16,>=0.15; extra == "benchmark"
|
|
46
|
+
Requires-Dist: optuna; extra == "benchmark"
|
|
47
|
+
Dynamic: author
|
|
48
|
+
Dynamic: author-email
|
|
49
|
+
Dynamic: classifier
|
|
50
|
+
Dynamic: description
|
|
51
|
+
Dynamic: description-content-type
|
|
52
|
+
Dynamic: home-page
|
|
53
|
+
Dynamic: keywords
|
|
54
|
+
Dynamic: license
|
|
55
|
+
Dynamic: license-file
|
|
56
|
+
Dynamic: project-url
|
|
57
|
+
Dynamic: provides-extra
|
|
58
|
+
Dynamic: requires-dist
|
|
59
|
+
Dynamic: requires-python
|
|
60
|
+
Dynamic: summary
|
|
61
|
+
|
|
62
|
+
|CI| |Doc| |Licence|
|
|
63
|
+
|
|
64
|
+
|Logo|
|
|
65
|
+
|
|
66
|
+
SKSurrogate
|
|
67
|
+
==================
|
|
68
|
+
**Lightweight, maintained, scikit-learn-native surrogate tuner — a drop-in replacement for
|
|
69
|
+
``BayesSearchCV``.**
|
|
70
|
+
|
|
71
|
+
``SKSurrogate`` searches expensive objectives (hyperparameters, AutoML pipelines) with a
|
|
72
|
+
surrogate response surface built on ``scikit-learn``. The tuner is a ``BaseSearchCV``
|
|
73
|
+
subclass, so it plugs into existing scikit-learn code with the same ``fit``/``predict``
|
|
74
|
+
contract as ``GridSearchCV``, ``RandomizedSearchCV``, or ``BayesSearchCV`` — no new estimator
|
|
75
|
+
API, no framework lock-in.
|
|
76
|
+
|
|
77
|
+
Why not Optuna / vanilla BO?
|
|
78
|
+
----------------------------
|
|
79
|
+
- **Inequality constraints** (``ineq``): constrain the search region directly, rather than
|
|
80
|
+
through penalty tricks or rejection sampling.
|
|
81
|
+
- **Trust-region contraction dynamics** (``contraction=0.9``): TuRBO/DYCORS-style radius
|
|
82
|
+
contraction that keeps the search focused as it converges, scaling to medium- and
|
|
83
|
+
high-dimensional spaces.
|
|
84
|
+
- **scikit-learn-native**: the tuner *is* a ``BaseSearchCV`` — it composes with pipelines,
|
|
85
|
+
cross-validation, and the rest of the scikit-learn ecosystem.
|
|
86
|
+
- **Drift-aware** (see below): it records the identity of the data it optimized, so you can
|
|
87
|
+
detect drift before inference.
|
|
88
|
+
|
|
89
|
+
The hybrid loop
|
|
90
|
+
---------------
|
|
91
|
+
Two cooperating search layers are the centerpiece of the package:
|
|
92
|
+
|
|
93
|
+
- **Evolutionary pipeline selector** (``EOA``): explores the space of transformers and
|
|
94
|
+
estimators to assemble candidate pipelines.
|
|
95
|
+
- **Local surrogate tuner** (``SurrogateRandomCV``): fits a response surface to the best
|
|
96
|
+
candidates and focuses evaluations where the surrogate predicts improvement.
|
|
97
|
+
|
|
98
|
+
This hybrid — global structure search plus local surrogate refinement — is what makes
|
|
99
|
+
``SKSurrogate`` a pipeline *designer* rather than just a hyperparameter tuner.
|
|
100
|
+
|
|
101
|
+
Since v0.2 the default response surface is a stock, un-tuned RBF Gaussian process (chosen over
|
|
102
|
+
the previous cubic Hilbert polynomial on the evidence of the equal-budget benchmark suite); a
|
|
103
|
+
custom regressor based on Hilbert Space techniques is still available (``HilbertRegressor``),
|
|
104
|
+
and all ``scikit-learn`` regressors are accepted for optimization.
|
|
105
|
+
|
|
106
|
+
Understand what you tuned
|
|
107
|
+
-------------------------
|
|
108
|
+
Once a run has finished, ``SKSurrogate`` explains *what* the fitted model depends on — not just
|
|
109
|
+
*where* the search stopped:
|
|
110
|
+
|
|
111
|
+
- **Model explanations**: permutation importance, partial dependence, and accumulated local
|
|
112
|
+
effects for a stored model bundle show which features drive its predictions globally, while
|
|
113
|
+
an exact row-level explanation reconstructs one prediction from its baseline as ordered
|
|
114
|
+
feature contributions. Available through the control plane (``explain``, ``ale`` and
|
|
115
|
+
``explain/row`` endpoints) and in the web UI; see the
|
|
116
|
+
`control-plane guide <https://sksurrogate.readthedocs.io/en/latest/controlplane.html>`_ and the
|
|
117
|
+
`scientific workflow guide <https://sksurrogate.readthedocs.io/en/latest/mltrace.html>`_.
|
|
118
|
+
- **Sensitivity analysis**: Sobol, Morris, and moment-independent δ indices quantify which
|
|
119
|
+
inputs dominate output variance — useful for pruning expensive models or diagnosing a tuned
|
|
120
|
+
pipeline. See the `sensitivity analysis guide <https://sksurrogate.readthedocs.io/en/latest/sensitivity.html>`_.
|
|
121
|
+
|
|
122
|
+
Both are descriptive, model-attributive analyses: they quantify how the learned response depends
|
|
123
|
+
on its inputs, not causal effects.
|
|
124
|
+
|
|
125
|
+
Observe what a run did
|
|
126
|
+
----------------------
|
|
127
|
+
Search progress goes through the standard library ``logging`` module (``SKSurrogate`` loggers, with
|
|
128
|
+
``WARNING``/``ERROR`` for degraded surrogate fits, stagnation and failures), and the core exposes
|
|
129
|
+
per-trial telemetry: a per-refit ``fit_score``, ``init``/``explore``/``surrogate_exploit`` sampling
|
|
130
|
+
tags, a ``callbacks`` hook that delivers one event per evaluated candidate, and a JSON-safe
|
|
131
|
+
``to_audit_dict()`` export. The control plane captures those records per background job into a
|
|
132
|
+
**Logs** page with severity, dataset/task and research-project filters — see the
|
|
133
|
+
`telemetry contract <https://sksurrogate.readthedocs.io/en/latest/telemetry.html>`_,
|
|
134
|
+
the `log endpoints <https://sksurrogate.readthedocs.io/en/latest/controlplane.html>`_
|
|
135
|
+
and the `UI manual <https://sksurrogate.readthedocs.io/en/latest/ui-manual.html>`_.
|
|
136
|
+
|
|
137
|
+
Quick start
|
|
138
|
+
-----------
|
|
139
|
+
``SurrogateRandomCV`` is a drop-in for ``RandomizedSearchCV``; ranges can be written as plain
|
|
140
|
+
tuples (integers or floats) and lists (categorical values)::
|
|
141
|
+
|
|
142
|
+
from sklearn.svm import SVC
|
|
143
|
+
from SKSurrogate import SurrogateRandomCV
|
|
144
|
+
|
|
145
|
+
search = SurrogateRandomCV(
|
|
146
|
+
SVC(),
|
|
147
|
+
param_distributions={"C": (1e-3, 10.0), "kernel": ["poly", "rbf"], "degree": (1, 4)},
|
|
148
|
+
n_iter=30,
|
|
149
|
+
).fit(X, y)
|
|
150
|
+
search.best_params_, search.best_score_
|
|
151
|
+
|
|
152
|
+
For automatic pipeline design, ``AML(preset="classification").fit(X, y)`` (or
|
|
153
|
+
``preset="regression"``) needs no search configuration. For pandas DataFrames,
|
|
154
|
+
the preset automatically fits numeric, categorical, datetime, and text
|
|
155
|
+
preprocessing inside each cross-validation fold when ``cat_cols`` is omitted.
|
|
156
|
+
Array-like inputs should already be numeric; ``cat_cols`` retains the explicit
|
|
157
|
+
categorical-encoding path. ``fit(X, y, strategy="eoa")`` selects evolutionary
|
|
158
|
+
search.
|
|
159
|
+
|
|
160
|
+
More workflows are covered in the
|
|
161
|
+
`surrogate-search guide <https://sksurrogate.readthedocs.io/en/latest/surrogate.html>`_,
|
|
162
|
+
`preprocessing guide <https://sksurrogate.readthedocs.io/en/latest/dataproc.html>`_,
|
|
163
|
+
`scientific workflow guide <https://sksurrogate.readthedocs.io/en/latest/mltrace.html>`_,
|
|
164
|
+
`experiment design guide <https://sksurrogate.readthedocs.io/en/latest/experiment-design.html>`_,
|
|
165
|
+
`research projects guide <https://sksurrogate.readthedocs.io/en/latest/research-projects.html>`_,
|
|
166
|
+
and `monitoring guide <https://sksurrogate.readthedocs.io/en/latest/monitoring.html>`_.
|
|
167
|
+
For the API and UI, see the
|
|
168
|
+
`control-plane guide <https://sksurrogate.readthedocs.io/en/latest/controlplane.html>`_
|
|
169
|
+
`UI manual <https://sksurrogate.readthedocs.io/en/latest/ui-manual.html>`_ and
|
|
170
|
+
`worked example with screenshots <https://sksurrogate.readthedocs.io/en/latest/walkthrough.html>`_.
|
|
171
|
+
|
|
172
|
+
Run the web UI and API with Docker
|
|
173
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
174
|
+
|
|
175
|
+
From a source checkout (Docker with Compose required)::
|
|
176
|
+
|
|
177
|
+
docker compose --profile prod up --build -d # UI and API on http://localhost:8013
|
|
178
|
+
docker compose --profile dev up --build # hot reload; UI on http://localhost:5174
|
|
179
|
+
|
|
180
|
+
Set ``SKSURROGATE_PORT`` to change the port and ``SKSURROGATE_API_KEY`` to
|
|
181
|
+
require an API key; for any published port also set
|
|
182
|
+
``SKSURROGATE_REQUIRE_AUTH=1`` so the container refuses to start without a key.
|
|
183
|
+
Data persists in the ``sksurrogate-data`` volume. See the control-plane guide
|
|
184
|
+
for details.
|
|
185
|
+
|
|
186
|
+
Benchmarks
|
|
187
|
+
----------
|
|
188
|
+
The surrogate-guided search is validated against strong HPO/AutoML baselines at **equal
|
|
189
|
+
evaluation budgets** (candidate-model evaluations, not wall-clock). Mean final cross-validated
|
|
190
|
+
accuracy over 7 seeds at a budget of 30 evaluations (full protocol, figures, and the raw-results
|
|
191
|
+
archive DOI `10.5281/zenodo.23629024 <https://doi.org/10.5281/zenodo.23629024>`_ are in
|
|
192
|
+
`docs/benchmarks.md <docs/benchmarks.md>`_):
|
|
193
|
+
|
|
194
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
195
|
+
| dataset | SKSurrogate (RBF-GP, v0.2) | no surrogate | random | Optuna-TPE |
|
|
196
|
+
+============+============================+==============+========+============+
|
|
197
|
+
| arrhythmia | 0.7020 | 0.6910 | 0.6941 | **0.7036** |
|
|
198
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
199
|
+
| credit-g | 0.7423 | 0.7391 | 0.7405 | **0.7436** |
|
|
200
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
201
|
+
| galaxy3 | 0.6473 | 0.6448 | 0.6484 | **0.6507** |
|
|
202
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
203
|
+
| ionosphere | **0.9352** | 0.9347 | 0.9347 | 0.9337 |
|
|
204
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
205
|
+
| optdigits | 0.9403 | 0.9392 | 0.9380 | **0.9405** |
|
|
206
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
207
|
+
| spambase | 0.9280 | 0.9269 | 0.9272 | **0.9286** |
|
|
208
|
+
+------------+----------------------------+--------------+--------+------------+
|
|
209
|
+
|
|
210
|
+
The RBF-GP response surface matches the top baseline within ~0.002 on every dataset and edges
|
|
211
|
+
it out on the hardest case (ionosphere); the with-vs-without surrogate ablation
|
|
212
|
+
(``srs-no-surrogate``) shows the surrogate raises or matches final accuracy on every dataset.
|
|
213
|
+
At the extended budget of 60 evaluations, SKSurrogate (RBF-GP) leads all six datasets.
|
|
214
|
+
Median-evaluations-to-target and seed-averaged best-so-far curves are in the benchmark report.
|
|
215
|
+
|
|
216
|
+
Optimize with confidence: detect drift before inference
|
|
217
|
+
-------------------------------------------------------
|
|
218
|
+
``SKSurrogate`` records a deterministic dataset fingerprint and a JSON-serializable schema for
|
|
219
|
+
each tracked dataset. Each call to ``mltrack.register_data(...)`` stores dataset metadata,
|
|
220
|
+
including the target column, row count, column names, dtypes, nullability, and categorical
|
|
221
|
+
values. This lets a run be identified and later compared against a different dataset or a
|
|
222
|
+
refreshed training sample — a differentiator that Optuna, TPOT, and SMAC all lack, because they
|
|
223
|
+
ignore data identity entirely.
|
|
224
|
+
|
|
225
|
+
The tracker also exposes ``validate_data(...)`` and ``validate_prediction_data(...)`` to compare
|
|
226
|
+
incoming data against the stored schema before training or inference. By default the checks are
|
|
227
|
+
strict: missing columns, reordered columns, dtype mismatches, and unknown categorical values
|
|
228
|
+
fail with actionable errors. For compatibility workflows, these checks can be relaxed explicitly
|
|
229
|
+
with ``missing_columns='ignore'`` or ``unknown_categories='ignore'``.
|
|
230
|
+
|
|
231
|
+
The intended workflow is:
|
|
232
|
+
|
|
233
|
+
1. Register the training dataset with ``mltrack.register_data(frame, target)``.
|
|
234
|
+
2. Validate training data before fitting with ``tracker.validate_data(frame, target=...)``.
|
|
235
|
+
3. Validate prediction inputs with ``tracker.validate_prediction_data(frame)`` before calling
|
|
236
|
+
``predict`` on a model or pipeline.
|
|
237
|
+
4. Use the stored ``dataset_fingerprint`` and ``dataset_schema`` metadata for reproducibility,
|
|
238
|
+
drift checks, and auditability.
|
|
239
|
+
|
|
240
|
+
Installation
|
|
241
|
+
------------
|
|
242
|
+
From PyPI::
|
|
243
|
+
|
|
244
|
+
pip install sksurrogate
|
|
245
|
+
|
|
246
|
+
or from source (development)::
|
|
247
|
+
|
|
248
|
+
pip install git+https://github.com/mghasemi/sksurrogate.git
|
|
249
|
+
|
|
250
|
+
Optional extras
|
|
251
|
+
---------------
|
|
252
|
+
The package also ships a web UI, a control-plane API, and a run tracker. These are optional
|
|
253
|
+
add-ons — the optimizer above is the primary deliverable, and the extras are kept deliberately
|
|
254
|
+
out of the headline.
|
|
255
|
+
|
|
256
|
+
- **Web UI and control-plane API**: documented in the
|
|
257
|
+
`Web UI and Control-Plane API guide <https://sksurrogate.readthedocs.io/en/latest/controlplane.html>`_.
|
|
258
|
+
- **Step-by-step UI manual**: `screenshots and example CSV files <https://sksurrogate.readthedocs.io/en/latest/ui-manual.html>`_.
|
|
259
|
+
|
|
260
|
+
Dependencies
|
|
261
|
+
----------------
|
|
262
|
+
``SKSurrogate`` heavily depends on `NumPy <http://www.numpy.org/>`_,
|
|
263
|
+
`scipy <https://www.scipy.org/>`_, and `scikit-learn <https://scikit-learn.org/stable/>`_,
|
|
264
|
+
for its main functionalities. Other dependencies include `pandas <https://pandas.pydata.org/>`_,
|
|
265
|
+
`matplotlib <https://matplotlib.org/>`_, `SALib <https://github.com/SALib/SALib>`_,
|
|
266
|
+
`peewee <https://github.com/coleifer/peewee>`_, and
|
|
267
|
+
`tqdm <https://github.com/tqdm/tqdm>`_.
|
|
268
|
+
|
|
269
|
+
Documentation
|
|
270
|
+
----------------
|
|
271
|
+
The documentation is produced by `Sphinx <http://www.sphinx-doc.org/en/stable/>`_ and is intended to cover code usage
|
|
272
|
+
as well as a bit of theory to explain each method briefly.
|
|
273
|
+
For more details refer to the documentation at `sksurrogate.rtfd.io <http://sksurrogate.readthedocs.io/>`_.
|
|
274
|
+
|
|
275
|
+
License
|
|
276
|
+
================
|
|
277
|
+
This code is distributed under `MIT license <https://en.wikipedia.org/wiki/MIT_License>`_:
|
|
278
|
+
|
|
279
|
+
MIT License
|
|
280
|
+
----------------
|
|
281
|
+
|
|
282
|
+
Copyright (c) 2019--2026 Mehdi Ghasemi
|
|
283
|
+
|
|
284
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
285
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
286
|
+
in the Software without restriction, including without limitation the rights
|
|
287
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
288
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
289
|
+
furnished to do so, subject to the following conditions:
|
|
290
|
+
|
|
291
|
+
The above copyright notice and this permission notice shall be included in all
|
|
292
|
+
copies or substantial portions of the Software.
|
|
293
|
+
|
|
294
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
295
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
296
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
297
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
298
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
299
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
300
|
+
SOFTWARE.
|
|
301
|
+
|
|
302
|
+
.. |Logo| image:: ./docs/images/funnel.png
|
|
303
|
+
.. |CI| image:: https://github.com/mghasemi/sksurrogate/actions/workflows/ci.yml/badge.svg?branch=master
|
|
304
|
+
:target: https://github.com/mghasemi/sksurrogate/actions/workflows/ci.yml
|
|
305
|
+
.. |Doc| image:: https://readthedocs.org/projects/sksurrogate/badge/?version=latest
|
|
306
|
+
:target: https://sksurrogate.readthedocs.io/en/latest/?badge=latest
|
|
307
|
+
:alt: Documentation Status
|
|
308
|
+
.. |Licence| image:: https://img.shields.io/badge/license-MIT-blue.svg
|
|
309
|
+
:target: https://github.com/mghasemi/sksurrogate/blob/master/LICENSE
|
|
@@ -111,6 +111,201 @@ class DateTime2Num(TransformerMixin, BaseEstimator):
|
|
|
111
111
|
return self.transform(X)
|
|
112
112
|
|
|
113
113
|
|
|
114
|
+
def _datetime_frame_to_epoch_seconds(X):
|
|
115
|
+
transformed = pandas.DataFrame(index=X.index)
|
|
116
|
+
for column in X.columns:
|
|
117
|
+
values = pandas.to_datetime(X[column], errors="coerce")
|
|
118
|
+
seconds = values.astype("int64").astype(float) / 1e9
|
|
119
|
+
seconds[values.isna()] = numpy.nan
|
|
120
|
+
transformed[column] = seconds
|
|
121
|
+
return transformed
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _flatten_text_column(X):
|
|
125
|
+
return pandas.DataFrame(X).iloc[:, 0].fillna("").astype(str).to_numpy()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _is_declared_text_dtype(dtype) -> bool:
|
|
129
|
+
"""Whether ``dtype`` marks an explicitly declared text column.
|
|
130
|
+
|
|
131
|
+
pandas >= 3 infers plain string columns as a first-class ``StringDtype``
|
|
132
|
+
whose missing value is ``nan``, so an ``isinstance`` check alone can no
|
|
133
|
+
longer distinguish user-declared text from ordinary categorical strings.
|
|
134
|
+
Declared text columns (e.g. ``astype("string")`` or ``pandas.StringDtype()``)
|
|
135
|
+
carry :data:`pandas.NA` as their missing value on both pandas 2.x and 3.x;
|
|
136
|
+
only those receive TF-IDF vectorisation, while inferred string columns fall
|
|
137
|
+
through to one-hot encoding.
|
|
138
|
+
"""
|
|
139
|
+
return isinstance(dtype, pandas.StringDtype) and dtype.na_value is pandas.NA
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class FoldLocalDataPreprocessor(TransformerMixin, BaseEstimator):
|
|
143
|
+
"""Fit DataFrame preprocessing within the current training partition.
|
|
144
|
+
|
|
145
|
+
Use this transformer inside an sklearn ``Pipeline`` so every cross-
|
|
146
|
+
validation fold learns its own imputations, category vocabulary, and text
|
|
147
|
+
vocabulary. Numeric columns receive median imputation, booleans and
|
|
148
|
+
non-text object/category columns receive imputation and one-hot encoding,
|
|
149
|
+
datetimes are converted to epoch seconds and imputed. Explicitly declared
|
|
150
|
+
text columns (``astype("string")`` / ``pandas.StringDtype()``) receive
|
|
151
|
+
per-column TF-IDF features; on pandas >= 3, plain string columns are
|
|
152
|
+
inferred as a first-class string dtype and fall back to one-hot encoding
|
|
153
|
+
like object columns.
|
|
154
|
+
|
|
155
|
+
The existing :class:`DataPreprocess` class remains available for eager
|
|
156
|
+
whole-frame transformations; this transformer is the leakage-safe choice
|
|
157
|
+
when preprocessing is part of model selection or cross-validation.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
def __init__(self, scale_numeric=False):
|
|
161
|
+
self.scale_numeric = scale_numeric
|
|
162
|
+
|
|
163
|
+
def fit(self, X, y=None):
|
|
164
|
+
from sklearn.compose import ColumnTransformer
|
|
165
|
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
166
|
+
from sklearn.impute import SimpleImputer
|
|
167
|
+
from sklearn.pipeline import Pipeline
|
|
168
|
+
from sklearn.preprocessing import FunctionTransformer, OneHotEncoder, StandardScaler
|
|
169
|
+
|
|
170
|
+
if not isinstance(X, pandas.DataFrame):
|
|
171
|
+
raise TypeError("FoldLocalDataPreprocessor requires a pandas DataFrame")
|
|
172
|
+
if X.columns.has_duplicates:
|
|
173
|
+
raise ValueError("FoldLocalDataPreprocessor requires unique column names")
|
|
174
|
+
if X.shape[1] == 0:
|
|
175
|
+
raise ValueError("FoldLocalDataPreprocessor requires at least one feature")
|
|
176
|
+
|
|
177
|
+
self._input_columns = list(X.columns)
|
|
178
|
+
self.n_features_in_ = X.shape[1]
|
|
179
|
+
if hasattr(self, "feature_names_in_"):
|
|
180
|
+
del self.feature_names_in_
|
|
181
|
+
if all(isinstance(column, str) for column in self._input_columns):
|
|
182
|
+
self.feature_names_in_ = numpy.asarray(self._input_columns, dtype=object)
|
|
183
|
+
|
|
184
|
+
numeric_columns = []
|
|
185
|
+
categorical_columns = []
|
|
186
|
+
datetime_columns = []
|
|
187
|
+
text_columns = []
|
|
188
|
+
for index, column in enumerate(X.columns):
|
|
189
|
+
dtype = X[column].dtype
|
|
190
|
+
if pandas.api.types.is_datetime64_any_dtype(dtype):
|
|
191
|
+
datetime_columns.append(index)
|
|
192
|
+
elif _is_declared_text_dtype(dtype):
|
|
193
|
+
text_columns.append(index)
|
|
194
|
+
elif isinstance(dtype, pandas.StringDtype):
|
|
195
|
+
# pandas >= 3 infers plain string columns as a first-class
|
|
196
|
+
# StringDtype; only explicitly declared ones are text.
|
|
197
|
+
categorical_columns.append(index)
|
|
198
|
+
elif pandas.api.types.is_bool_dtype(dtype):
|
|
199
|
+
categorical_columns.append(index)
|
|
200
|
+
elif pandas.api.types.is_numeric_dtype(dtype):
|
|
201
|
+
numeric_columns.append(index)
|
|
202
|
+
else:
|
|
203
|
+
categorical_columns.append(index)
|
|
204
|
+
|
|
205
|
+
transformers = []
|
|
206
|
+
if numeric_columns:
|
|
207
|
+
numeric_steps = [
|
|
208
|
+
("imputer", SimpleImputer(strategy="median", keep_empty_features=True))
|
|
209
|
+
]
|
|
210
|
+
if self.scale_numeric:
|
|
211
|
+
numeric_steps.append(("scaler", StandardScaler()))
|
|
212
|
+
transformers.append(
|
|
213
|
+
(
|
|
214
|
+
"numeric",
|
|
215
|
+
Pipeline(numeric_steps),
|
|
216
|
+
numeric_columns,
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
if categorical_columns:
|
|
220
|
+
transformers.append(
|
|
221
|
+
(
|
|
222
|
+
"categorical",
|
|
223
|
+
Pipeline(
|
|
224
|
+
[
|
|
225
|
+
(
|
|
226
|
+
"imputer",
|
|
227
|
+
SimpleImputer(
|
|
228
|
+
strategy="constant",
|
|
229
|
+
fill_value="__MISSING__",
|
|
230
|
+
keep_empty_features=True,
|
|
231
|
+
),
|
|
232
|
+
),
|
|
233
|
+
("onehot", OneHotEncoder(handle_unknown="ignore")),
|
|
234
|
+
]
|
|
235
|
+
),
|
|
236
|
+
categorical_columns,
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
if datetime_columns:
|
|
240
|
+
datetime_steps = [
|
|
241
|
+
(
|
|
242
|
+
"epoch_seconds",
|
|
243
|
+
FunctionTransformer(
|
|
244
|
+
_datetime_frame_to_epoch_seconds,
|
|
245
|
+
feature_names_out="one-to-one",
|
|
246
|
+
),
|
|
247
|
+
),
|
|
248
|
+
("imputer", SimpleImputer(strategy="median", keep_empty_features=True)),
|
|
249
|
+
]
|
|
250
|
+
if self.scale_numeric:
|
|
251
|
+
datetime_steps.append(("scaler", StandardScaler()))
|
|
252
|
+
transformers.append(
|
|
253
|
+
(
|
|
254
|
+
"datetime",
|
|
255
|
+
Pipeline(datetime_steps),
|
|
256
|
+
datetime_columns,
|
|
257
|
+
)
|
|
258
|
+
)
|
|
259
|
+
for index in text_columns:
|
|
260
|
+
transformers.append(
|
|
261
|
+
(
|
|
262
|
+
"text_%d" % index,
|
|
263
|
+
Pipeline(
|
|
264
|
+
[
|
|
265
|
+
(
|
|
266
|
+
"flatten",
|
|
267
|
+
FunctionTransformer(
|
|
268
|
+
_flatten_text_column,
|
|
269
|
+
feature_names_out="one-to-one",
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
("tfidf", TfidfVectorizer(min_df=1)),
|
|
273
|
+
]
|
|
274
|
+
),
|
|
275
|
+
[index],
|
|
276
|
+
)
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
self.transformer_ = ColumnTransformer(
|
|
280
|
+
transformers,
|
|
281
|
+
remainder="drop",
|
|
282
|
+
verbose_feature_names_out=True,
|
|
283
|
+
)
|
|
284
|
+
self.transformer_.fit(X, y)
|
|
285
|
+
return self
|
|
286
|
+
|
|
287
|
+
def transform(self, X):
|
|
288
|
+
if not hasattr(self, "transformer_"):
|
|
289
|
+
raise RuntimeError("FoldLocalDataPreprocessor has not been fitted")
|
|
290
|
+
if not isinstance(X, pandas.DataFrame):
|
|
291
|
+
raise TypeError("FoldLocalDataPreprocessor requires a pandas DataFrame")
|
|
292
|
+
if X.columns.has_duplicates:
|
|
293
|
+
raise ValueError("FoldLocalDataPreprocessor requires unique column names")
|
|
294
|
+
missing = [column for column in self._input_columns if column not in X.columns]
|
|
295
|
+
extra = [column for column in X.columns if column not in self._input_columns]
|
|
296
|
+
if missing or extra:
|
|
297
|
+
raise ValueError(
|
|
298
|
+
"Input columns do not match fitted columns; missing=%r, extra=%r"
|
|
299
|
+
% (missing, extra)
|
|
300
|
+
)
|
|
301
|
+
return self.transformer_.transform(X.loc[:, self._input_columns])
|
|
302
|
+
|
|
303
|
+
def get_feature_names_out(self, input_features=None):
|
|
304
|
+
if not hasattr(self, "transformer_"):
|
|
305
|
+
raise RuntimeError("FoldLocalDataPreprocessor has not been fitted")
|
|
306
|
+
return self.transformer_.get_feature_names_out()
|
|
307
|
+
|
|
308
|
+
|
|
114
309
|
class DataPreprocess(object):
|
|
115
310
|
"""
|
|
116
311
|
This class performs a few reprocessing task on the input DataFrame to provide a ML ready dataset.
|
|
@@ -123,6 +318,11 @@ class DataPreprocess(object):
|
|
|
123
318
|
:param force_threshold: boolean, indicate whether to force the deduction based on the provided thresholds or not
|
|
124
319
|
:param imputer: the imputer object; default `IterativeImputer` for missing values imputation
|
|
125
320
|
:param force_impute: boolean; default `True` to indicate the desire for missing value imputation
|
|
321
|
+
|
|
322
|
+
.. note::
|
|
323
|
+
This is a one-shot, whole-frame encoder: types are deduced and missing values imputed on the entire
|
|
324
|
+
frame, which leaks information across cross-validation folds. For scikit-learn pipelines and
|
|
325
|
+
cross-validation use :class:`FoldLocalDataPreprocessor`, which has ``fit``/``transform``.
|
|
126
326
|
"""
|
|
127
327
|
|
|
128
328
|
def __init__(self, df, bin_threshold=.1, cat_threshold=.1, force_threshold=False, imputer=None, force_impute=True,
|
|
@@ -201,6 +401,13 @@ class DataPreprocess(object):
|
|
|
201
401
|
return True
|
|
202
402
|
return False
|
|
203
403
|
|
|
404
|
+
def is_numeric_string(self, clmn):
|
|
405
|
+
"""Return whether an object column contains only numeric values and nulls."""
|
|
406
|
+
if self.types[clmn] != 'object':
|
|
407
|
+
return False
|
|
408
|
+
values = pandas.to_numeric(self.df[clmn].dropna(), errors='coerce')
|
|
409
|
+
return len(values) > 0 and values.notna().all()
|
|
410
|
+
|
|
204
411
|
def is_datetime(self, clmn):
|
|
205
412
|
"""
|
|
206
413
|
Determines if the type of the data for the column `clmn` is datetime or not
|
|
@@ -291,7 +498,12 @@ class DataPreprocess(object):
|
|
|
291
498
|
for clmn in self.columns:
|
|
292
499
|
if clmn in self.pivot_types:
|
|
293
500
|
continue
|
|
294
|
-
if self.
|
|
501
|
+
if self.is_numeric_string(clmn):
|
|
502
|
+
values = pandas.to_numeric(self.df[clmn].dropna(), errors='coerce')
|
|
503
|
+
typ = 'int64' if (values % 1 == 0).all() else 'float64'
|
|
504
|
+
self.deduced_types[typ].append(clmn)
|
|
505
|
+
self.pivot_types[clmn] = typ
|
|
506
|
+
elif self.is_label(clmn):
|
|
295
507
|
self.deduced_types['label'].append(clmn)
|
|
296
508
|
self.pivot_types[clmn] = 'label'
|
|
297
509
|
elif self.is_text(clmn):
|
|
@@ -255,10 +255,28 @@ class FunctionSpace(object):
|
|
|
255
255
|
is a list of function that are orthogonal to each other with
|
|
256
256
|
respect to the measure ``measure`` over the given range ``domain``.
|
|
257
257
|
"""
|
|
258
|
+
import numpy as np
|
|
258
259
|
from numpy.linalg import det
|
|
259
260
|
from numpy import sqrt
|
|
260
261
|
|
|
261
262
|
N = len(self.base)
|
|
263
|
+
self.GramMat()
|
|
264
|
+
if not np.isfinite(self.Gram).all():
|
|
265
|
+
raise ValueError("The Gram matrix contains non-finite values")
|
|
266
|
+
rank = np.linalg.matrix_rank(self.Gram)
|
|
267
|
+
if rank < N:
|
|
268
|
+
raise ValueError(
|
|
269
|
+
"The function basis is linearly dependent under the specified "
|
|
270
|
+
"measure (rank %d for %d functions); reduce the basis size or "
|
|
271
|
+
"provide more independent support points." % (rank, N)
|
|
272
|
+
)
|
|
273
|
+
try:
|
|
274
|
+
np.linalg.cholesky(self.Gram)
|
|
275
|
+
except np.linalg.LinAlgError as exc:
|
|
276
|
+
raise ValueError(
|
|
277
|
+
"The Gram matrix is not positive definite; the function basis "
|
|
278
|
+
"is numerically ill-conditioned under the specified measure."
|
|
279
|
+
) from exc
|
|
262
280
|
GramDets = [1.0] + [det(self.minor_gram(i)) for i in range(N)]
|
|
263
281
|
B = []
|
|
264
282
|
D = []
|
|
@@ -405,6 +423,9 @@ class HilbertRegressor(BaseEstimator, RegressorMixin):
|
|
|
405
423
|
on `fit` inputs
|
|
406
424
|
:param fspace: NpyProximation.FunctionBasis, default = None
|
|
407
425
|
the function subspace of :math:`L_2(\mu)`, if `None` it will be initiated according to `self.meas`
|
|
426
|
+
|
|
427
|
+
A fit raises ``ValueError`` when the supplied basis is rank-deficient or
|
|
428
|
+
numerically ill-conditioned under the selected measure.
|
|
408
429
|
"""
|
|
409
430
|
|
|
410
431
|
def __init__(self, deg=3, base=None, meas=None, fspace=None):
|
|
@@ -27,8 +27,11 @@ from .mltrace import (
|
|
|
27
27
|
default_cv_spec,
|
|
28
28
|
mltrack,
|
|
29
29
|
np2df,
|
|
30
|
+
prediction_interval_diagnostics,
|
|
31
|
+
split_conformal_regression_interval,
|
|
32
|
+
split_conformal_quantile_interval,
|
|
30
33
|
)
|
|
31
|
-
from .DataProcess import DataPreprocess
|
|
34
|
+
from .DataProcess import DataPreprocess, FoldLocalDataPreprocessor
|
|
32
35
|
from .ci import BundleQualityGateError, assert_bundle_quality, check_bundle_quality
|
|
33
36
|
from .deployment import DeploymentApprovalGate
|
|
34
37
|
from .execution import DaskExecutionBackend, ExecutionBackend, LocalProcessExecutionBackend
|
|
@@ -37,6 +40,7 @@ from .inference import SchemaValidationError, create_app, predict_batch, serve
|
|
|
37
40
|
from .monitoring import (
|
|
38
41
|
InferenceMonitor,
|
|
39
42
|
delayed_label_performance,
|
|
43
|
+
dataset_profile,
|
|
40
44
|
drift_report,
|
|
41
45
|
fairness_report,
|
|
42
46
|
loss_report,
|
|
@@ -46,8 +50,9 @@ from .monitoring import (
|
|
|
46
50
|
)
|
|
47
51
|
from .retraining import RetrainingJob
|
|
48
52
|
from .synthdat import SynthData
|
|
53
|
+
from .design import latin_hypercube, suggest_next_point
|
|
49
54
|
|
|
50
|
-
__version__ = "0.
|
|
55
|
+
__version__ = "0.3.0"
|
|
51
56
|
|
|
52
57
|
__all__ = [
|
|
53
58
|
"AML",
|
|
@@ -60,6 +65,7 @@ __all__ = [
|
|
|
60
65
|
"cv_to_spec",
|
|
61
66
|
"default_cv_spec",
|
|
62
67
|
"DataPreprocess",
|
|
68
|
+
"FoldLocalDataPreprocessor",
|
|
63
69
|
"DeploymentApprovalGate",
|
|
64
70
|
"DaskExecutionBackend",
|
|
65
71
|
"ExecutionBackend",
|
|
@@ -88,6 +94,9 @@ __all__ = [
|
|
|
88
94
|
"UniformRand",
|
|
89
95
|
"Words",
|
|
90
96
|
"mltrack",
|
|
97
|
+
"prediction_interval_diagnostics",
|
|
98
|
+
"split_conformal_regression_interval",
|
|
99
|
+
"split_conformal_quantile_interval",
|
|
91
100
|
"assert_bundle_quality",
|
|
92
101
|
"check_bundle_quality",
|
|
93
102
|
"ModelBundle",
|
|
@@ -97,6 +106,9 @@ __all__ = [
|
|
|
97
106
|
"SchemaValidationError",
|
|
98
107
|
"create_app",
|
|
99
108
|
"serve",
|
|
109
|
+
"latin_hypercube",
|
|
110
|
+
"suggest_next_point",
|
|
111
|
+
"dataset_profile",
|
|
100
112
|
"drift_report",
|
|
101
113
|
"fairness_report",
|
|
102
114
|
"prediction_distribution_report",
|