wavetrainer 0.0.52__tar.gz → 0.1.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.
- {wavetrainer-0.0.52/wavetrainer.egg-info → wavetrainer-0.1.0}/PKG-INFO +1 -3
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/README.md +0 -1
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/requirements.txt +0 -1
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/setup.py +1 -1
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/__init__.py +1 -1
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/calibrator/calibrator_router.py +11 -12
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/xgboost/xgboost_model.py +2 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0/wavetrainer.egg-info}/PKG-INFO +1 -3
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer.egg-info/SOURCES.txt +0 -1
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer.egg-info/requires.txt +0 -1
- wavetrainer-0.0.52/wavetrainer/calibrator/mapie_calibrator.py +0 -80
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/LICENSE +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/MANIFEST.in +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/setup.cfg +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/tests/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/tests/model/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/tests/model/catboost_kwargs_test.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/tests/trainer_test.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/calibrator/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/calibrator/calibrator.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/calibrator/vennabers_calibrator.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/create.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/exceptions.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/fit.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_classifier_wrap.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_kwargs.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_model.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_regressor_wrap.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/model.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/model_router.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/tabpfn/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/tabpfn/tabpfn_model.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/xgboost/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/xgboost/early_stopper.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/xgboost/xgboost_logger.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model_type.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/params.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/base_selector_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/combined_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/constant_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/correlation_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/duplicate_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/non_categorical_numeric_columns.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/nonnumeric_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/pca_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/select_by_single_feature_performance_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/smart_correlation_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/unseen_reducer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/selector/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/selector/selector.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/trainer.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/class_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/combined_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/exponential_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/linear_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/noop_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/sigmoid_weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/weights.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/weights/weights_router.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/windower/__init__.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/windower/windower.py +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer.egg-info/dependency_links.txt +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer.egg-info/not-zip-safe +0 -0
- {wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wavetrainer
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.1.0
|
4
4
|
Summary: A library for automatically finding the optimal model within feature and hyperparameter space.
|
5
5
|
Home-page: https://github.com/8W9aG/wavetrainer
|
6
6
|
Author: Will Sackfield
|
@@ -20,7 +20,6 @@ Requires-Dist: numpy>=1.26.4
|
|
20
20
|
Requires-Dist: scipy>=1.15.2
|
21
21
|
Requires-Dist: catboost>=1.2.7
|
22
22
|
Requires-Dist: venn-abers>=1.4.6
|
23
|
-
Requires-Dist: mapie>=0.9.2
|
24
23
|
Requires-Dist: pytz>=2025.1
|
25
24
|
Requires-Dist: torch>=2.6.0
|
26
25
|
Requires-Dist: tabpfn>=2.0.6
|
@@ -53,7 +52,6 @@ Python 3.11.6:
|
|
53
52
|
- [scipy](https://scipy.org/)
|
54
53
|
- [catboost](https://catboost.ai/)
|
55
54
|
- [venn-abers](https://github.com/ip200/venn-abers)
|
56
|
-
- [mapie](https://mapie.readthedocs.io/en/stable/)
|
57
55
|
- [pytz](https://pythonhosted.org/pytz/)
|
58
56
|
- [torch](https://pytorch.org/)
|
59
57
|
- [tabpfn](https://github.com/PriorLabs/TabPFN)
|
@@ -23,7 +23,6 @@ Python 3.11.6:
|
|
23
23
|
- [scipy](https://scipy.org/)
|
24
24
|
- [catboost](https://catboost.ai/)
|
25
25
|
- [venn-abers](https://github.com/ip200/venn-abers)
|
26
|
-
- [mapie](https://mapie.readthedocs.io/en/stable/)
|
27
26
|
- [pytz](https://pythonhosted.org/pytz/)
|
28
27
|
- [torch](https://pytorch.org/)
|
29
28
|
- [tabpfn](https://github.com/PriorLabs/TabPFN)
|
@@ -23,7 +23,7 @@ def install_requires() -> typing.List[str]:
|
|
23
23
|
|
24
24
|
setup(
|
25
25
|
name='wavetrainer',
|
26
|
-
version='0.0
|
26
|
+
version='0.1.0',
|
27
27
|
description='A library for automatically finding the optimal model within feature and hyperparameter space.',
|
28
28
|
long_description=long_description,
|
29
29
|
long_description_content_type='text/markdown',
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""A calibrator class that routes to other calibrators."""
|
2
2
|
|
3
3
|
import json
|
4
|
+
import logging
|
4
5
|
import os
|
5
6
|
from typing import Self
|
6
7
|
|
@@ -10,14 +11,12 @@ import pandas as pd
|
|
10
11
|
from ..model.model import Model
|
11
12
|
from ..model_type import ModelType, determine_model_type
|
12
13
|
from .calibrator import Calibrator
|
13
|
-
from .mapie_calibrator import MAPIECalibrator
|
14
14
|
from .vennabers_calibrator import VennabersCalibrator
|
15
15
|
|
16
16
|
_CALIBRATOR_ROUTER_FILE = "calibrator_router.json"
|
17
17
|
_CALIBRATOR_KEY = "calibrator"
|
18
18
|
_CALIBRATORS = {
|
19
19
|
VennabersCalibrator.name(): VennabersCalibrator,
|
20
|
-
MAPIECalibrator.name(): MAPIECalibrator,
|
21
20
|
}
|
22
21
|
|
23
22
|
|
@@ -40,10 +39,6 @@ class CalibratorRouter(Calibrator):
|
|
40
39
|
calibrator = self._calibrator
|
41
40
|
if calibrator is not None:
|
42
41
|
return calibrator.predictions_as_x(None)
|
43
|
-
if y is None:
|
44
|
-
raise ValueError("y is null")
|
45
|
-
if determine_model_type(y) == ModelType.REGRESSION:
|
46
|
-
return False
|
47
42
|
return True
|
48
43
|
|
49
44
|
def set_options(
|
@@ -55,9 +50,11 @@ class CalibratorRouter(Calibrator):
|
|
55
50
|
calibrator.set_options(trial, df)
|
56
51
|
|
57
52
|
def load(self, folder: str) -> None:
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
file_path = os.path.join(folder, _CALIBRATOR_ROUTER_FILE)
|
54
|
+
if not os.path.exists(file_path):
|
55
|
+
logging.warning("file %s does not exist", file_path)
|
56
|
+
return
|
57
|
+
with open(file_path, encoding="utf8") as handle:
|
61
58
|
params = json.load(handle)
|
62
59
|
calibrator = _CALIBRATORS[params[_CALIBRATOR_KEY]](self._model)
|
63
60
|
calibrator.load(folder)
|
@@ -66,7 +63,8 @@ class CalibratorRouter(Calibrator):
|
|
66
63
|
def save(self, folder: str, trial: optuna.Trial | optuna.trial.FrozenTrial) -> None:
|
67
64
|
calibrator = self._calibrator
|
68
65
|
if calibrator is None:
|
69
|
-
|
66
|
+
logging.warning("calibrator is null")
|
67
|
+
return
|
70
68
|
calibrator.save(folder, trial)
|
71
69
|
with open(
|
72
70
|
os.path.join(folder, _CALIBRATOR_ROUTER_FILE), "w", encoding="utf8"
|
@@ -91,7 +89,7 @@ class CalibratorRouter(Calibrator):
|
|
91
89
|
if y is None:
|
92
90
|
raise ValueError("y is null")
|
93
91
|
if determine_model_type(y) == ModelType.REGRESSION:
|
94
|
-
|
92
|
+
return self
|
95
93
|
else:
|
96
94
|
calibrator = VennabersCalibrator(self._model)
|
97
95
|
calibrator.fit(df, y=y, w=w)
|
@@ -101,5 +99,6 @@ class CalibratorRouter(Calibrator):
|
|
101
99
|
def transform(self, df: pd.DataFrame) -> pd.DataFrame:
|
102
100
|
calibrator = self._calibrator
|
103
101
|
if calibrator is None:
|
104
|
-
|
102
|
+
logging.warning("calibrator is null")
|
103
|
+
return df
|
105
104
|
return calibrator.transform(df)
|
@@ -275,6 +275,8 @@ class XGBoostModel(Model):
|
|
275
275
|
if eval_x is not None and eval_y is not None and self._best_iteration is None:
|
276
276
|
eval_x = _convert_categoricals(eval_x)
|
277
277
|
evals = [(eval_x, eval_y), (df, y)]
|
278
|
+
if w is not None:
|
279
|
+
w = w.fillna(0.0).clip(lower=0.00001)
|
278
280
|
xgboost.fit( # type: ignore
|
279
281
|
df,
|
280
282
|
y,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wavetrainer
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.1.0
|
4
4
|
Summary: A library for automatically finding the optimal model within feature and hyperparameter space.
|
5
5
|
Home-page: https://github.com/8W9aG/wavetrainer
|
6
6
|
Author: Will Sackfield
|
@@ -20,7 +20,6 @@ Requires-Dist: numpy>=1.26.4
|
|
20
20
|
Requires-Dist: scipy>=1.15.2
|
21
21
|
Requires-Dist: catboost>=1.2.7
|
22
22
|
Requires-Dist: venn-abers>=1.4.6
|
23
|
-
Requires-Dist: mapie>=0.9.2
|
24
23
|
Requires-Dist: pytz>=2025.1
|
25
24
|
Requires-Dist: torch>=2.6.0
|
26
25
|
Requires-Dist: tabpfn>=2.0.6
|
@@ -53,7 +52,6 @@ Python 3.11.6:
|
|
53
52
|
- [scipy](https://scipy.org/)
|
54
53
|
- [catboost](https://catboost.ai/)
|
55
54
|
- [venn-abers](https://github.com/ip200/venn-abers)
|
56
|
-
- [mapie](https://mapie.readthedocs.io/en/stable/)
|
57
55
|
- [pytz](https://pythonhosted.org/pytz/)
|
58
56
|
- [torch](https://pytorch.org/)
|
59
57
|
- [tabpfn](https://github.com/PriorLabs/TabPFN)
|
@@ -23,7 +23,6 @@ wavetrainer.egg-info/top_level.txt
|
|
23
23
|
wavetrainer/calibrator/__init__.py
|
24
24
|
wavetrainer/calibrator/calibrator.py
|
25
25
|
wavetrainer/calibrator/calibrator_router.py
|
26
|
-
wavetrainer/calibrator/mapie_calibrator.py
|
27
26
|
wavetrainer/calibrator/vennabers_calibrator.py
|
28
27
|
wavetrainer/model/__init__.py
|
29
28
|
wavetrainer/model/model.py
|
@@ -1,80 +0,0 @@
|
|
1
|
-
"""A calibrator that implements MAPIE."""
|
2
|
-
|
3
|
-
import os
|
4
|
-
from typing import Self
|
5
|
-
|
6
|
-
import joblib # type: ignore
|
7
|
-
import optuna
|
8
|
-
import pandas as pd
|
9
|
-
from mapie.regression import MapieRegressor # type: ignore
|
10
|
-
|
11
|
-
from ..model.model import PROBABILITY_COLUMN_PREFIX, Model
|
12
|
-
from .calibrator import Calibrator
|
13
|
-
|
14
|
-
_CALIBRATOR_FILENAME = "mapie.joblib"
|
15
|
-
|
16
|
-
|
17
|
-
class MAPIECalibrator(Calibrator):
|
18
|
-
"""A class that uses MAPIE as a calibrator."""
|
19
|
-
|
20
|
-
# pylint: disable=too-many-positional-arguments,too-many-arguments
|
21
|
-
|
22
|
-
def __init__(self, model: Model):
|
23
|
-
super().__init__(model)
|
24
|
-
self._mapie = MapieRegressor(model.create_estimator(), method="plus", cv=5)
|
25
|
-
|
26
|
-
@classmethod
|
27
|
-
def name(cls) -> str:
|
28
|
-
return "mapie"
|
29
|
-
|
30
|
-
def predictions_as_x(self, y: pd.Series | pd.DataFrame | None = None) -> bool:
|
31
|
-
return False
|
32
|
-
|
33
|
-
def set_options(
|
34
|
-
self, trial: optuna.Trial | optuna.trial.FrozenTrial, df: pd.DataFrame
|
35
|
-
) -> None:
|
36
|
-
pass
|
37
|
-
|
38
|
-
def load(self, folder: str) -> None:
|
39
|
-
self._mapie = joblib.load(os.path.join(folder, _CALIBRATOR_FILENAME))
|
40
|
-
|
41
|
-
def save(self, folder: str, trial: optuna.Trial | optuna.trial.FrozenTrial) -> None:
|
42
|
-
joblib.dump(self._mapie, os.path.join(folder, _CALIBRATOR_FILENAME))
|
43
|
-
|
44
|
-
def fit(
|
45
|
-
self,
|
46
|
-
df: pd.DataFrame,
|
47
|
-
y: pd.Series | pd.DataFrame | None = None,
|
48
|
-
w: pd.Series | None = None,
|
49
|
-
eval_x: pd.DataFrame | None = None,
|
50
|
-
eval_y: pd.Series | pd.DataFrame | None = None,
|
51
|
-
) -> Self:
|
52
|
-
mapie = self._mapie
|
53
|
-
if mapie is None:
|
54
|
-
raise ValueError("mapie is null")
|
55
|
-
if y is None:
|
56
|
-
raise ValueError("y is null")
|
57
|
-
mapie.fit(self._model.convert_df(df), y)
|
58
|
-
return self
|
59
|
-
|
60
|
-
def transform(self, df: pd.DataFrame) -> pd.DataFrame:
|
61
|
-
alpha = []
|
62
|
-
for potential_alpha in [0.05, 0.32]:
|
63
|
-
if (
|
64
|
-
len(df) > int(1.0 / potential_alpha) + 1
|
65
|
-
and len(df) > int(1.0 / (1.0 - potential_alpha)) + 1
|
66
|
-
):
|
67
|
-
alpha.append(potential_alpha)
|
68
|
-
ret_df = pd.DataFrame(index=df.index)
|
69
|
-
if alpha:
|
70
|
-
_, y_pis = self._mapie.predict(
|
71
|
-
self._model.convert_df(df), alpha=alpha, allow_infinite_bounds=True
|
72
|
-
)
|
73
|
-
for i in range(y_pis.shape[1]):
|
74
|
-
if i >= len(alpha):
|
75
|
-
continue
|
76
|
-
for ii in range(y_pis.shape[2]):
|
77
|
-
alpha_val = alpha[i]
|
78
|
-
values = y_pis[:, i, ii].flatten().tolist()
|
79
|
-
ret_df[f"{PROBABILITY_COLUMN_PREFIX}{alpha_val}_{ii == 1}"] = values
|
80
|
-
return ret_df
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_classifier_wrap.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/model/catboost/catboost_regressor_wrap.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{wavetrainer-0.0.52 → wavetrainer-0.1.0}/wavetrainer/reducer/non_categorical_numeric_columns.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|