lecrapaud 0.18.2__py3-none-any.whl → 0.18.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lecrapaud might be problematic. Click here for more details.
- lecrapaud/db/models/experiment.py +19 -10
- lecrapaud/feature_engineering.py +1 -1
- lecrapaud/model_selection.py +7 -4
- {lecrapaud-0.18.2.dist-info → lecrapaud-0.18.4.dist-info}/METADATA +1 -1
- {lecrapaud-0.18.2.dist-info → lecrapaud-0.18.4.dist-info}/RECORD +7 -7
- {lecrapaud-0.18.2.dist-info → lecrapaud-0.18.4.dist-info}/LICENSE +0 -0
- {lecrapaud-0.18.2.dist-info → lecrapaud-0.18.4.dist-info}/WHEEL +0 -0
|
@@ -25,7 +25,7 @@ from lecrapaud.db.models.score import Score
|
|
|
25
25
|
|
|
26
26
|
from lecrapaud.db.models.base import Base, with_db
|
|
27
27
|
from lecrapaud.db.models.utils import create_association_table
|
|
28
|
-
from lecrapaud.utils import logger
|
|
28
|
+
from lecrapaud.utils import logger, contains_best
|
|
29
29
|
|
|
30
30
|
# jointures
|
|
31
31
|
lecrapaud_experiment_target_association = create_association_table(
|
|
@@ -237,13 +237,27 @@ class Experiment(Base):
|
|
|
237
237
|
Returns:
|
|
238
238
|
Experiment or None: The experiment with the best score or None if not found
|
|
239
239
|
"""
|
|
240
|
+
experiments = db.query(cls).filter(cls.name.ilike(f"%{name}%")).all()
|
|
241
|
+
if not experiments:
|
|
242
|
+
logger.error(f"No experiments found with the given name: {name}")
|
|
243
|
+
return None
|
|
244
|
+
|
|
245
|
+
experiments = [
|
|
246
|
+
exp
|
|
247
|
+
for exp in experiments
|
|
248
|
+
if all(
|
|
249
|
+
[contains_best(f"{exp.path}/{target.name}") for target in exp.targets]
|
|
250
|
+
)
|
|
251
|
+
]
|
|
252
|
+
if not experiments:
|
|
253
|
+
logger.error(
|
|
254
|
+
f"No fully trained experiments found with the given name: {name}"
|
|
255
|
+
)
|
|
256
|
+
return None
|
|
257
|
+
|
|
240
258
|
if metric == "both":
|
|
241
259
|
# Calculate a combined score: average of normalized RMSE and LogLoss
|
|
242
260
|
# This ensures we're comparing apples to apples by normalizing the scores
|
|
243
|
-
experiments = db.query(cls).filter(cls.name.ilike(f"%{name}%")).all()
|
|
244
|
-
if not experiments:
|
|
245
|
-
logger.error(f"No experiments found with the given name: {name}")
|
|
246
|
-
return None
|
|
247
261
|
|
|
248
262
|
# Get all scores
|
|
249
263
|
rmse_scores = [e.avg_rmse for e in experiments if e.avg_rmse is not None]
|
|
@@ -284,11 +298,6 @@ class Experiment(Base):
|
|
|
284
298
|
|
|
285
299
|
elif metric == "rmse" or metric == "logloss":
|
|
286
300
|
# For single metric case (rmse or logloss)
|
|
287
|
-
# Need to get all experiments first to evaluate instance properties
|
|
288
|
-
experiments = db.query(cls).filter(cls.name.ilike(f"%{name}%")).all()
|
|
289
|
-
|
|
290
|
-
if not experiments:
|
|
291
|
-
return None
|
|
292
301
|
|
|
293
302
|
# Filter out experiments without scores and sort by the selected metric
|
|
294
303
|
filtered_experiments = []
|
lecrapaud/feature_engineering.py
CHANGED
|
@@ -220,7 +220,7 @@ class FeatureEngineeringEngine:
|
|
|
220
220
|
Returns:
|
|
221
221
|
pd.DataFrame: Original dataframe with new encoded columns added
|
|
222
222
|
"""
|
|
223
|
-
|
|
223
|
+
# TODO: target encoding needs to be fit / transform based at inference time.
|
|
224
224
|
df: pd.DataFrame = self.data
|
|
225
225
|
columns_te_groupby: list[list[str]] = self.columns_te_groupby
|
|
226
226
|
columns_te_target: list[str] = self.columns_te_target
|
lecrapaud/model_selection.py
CHANGED
|
@@ -12,6 +12,7 @@ import glob
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
import pickle
|
|
14
14
|
from pydantic import BaseModel
|
|
15
|
+
import ast
|
|
15
16
|
|
|
16
17
|
os.environ["COVERAGE_FILE"] = str(Path(".coverage").resolve())
|
|
17
18
|
|
|
@@ -122,6 +123,7 @@ class ModelEngine:
|
|
|
122
123
|
plot: bool = False,
|
|
123
124
|
log_dir: str = None,
|
|
124
125
|
):
|
|
126
|
+
self.threshold = None
|
|
125
127
|
self.path = path
|
|
126
128
|
if path:
|
|
127
129
|
self.load()
|
|
@@ -152,8 +154,6 @@ class ModelEngine:
|
|
|
152
154
|
else:
|
|
153
155
|
self.scaler_y = None
|
|
154
156
|
|
|
155
|
-
self.threshold = None
|
|
156
|
-
|
|
157
157
|
def fit(self, *args):
|
|
158
158
|
if self.recurrent:
|
|
159
159
|
fit = self.fit_recurrent
|
|
@@ -1070,7 +1070,7 @@ class ModelSelectionEngine:
|
|
|
1070
1070
|
best_score_overall = scores_tracking.iloc[0, :]
|
|
1071
1071
|
best_model_name = best_score_overall["MODEL_NAME"]
|
|
1072
1072
|
if self.target_type == "classification":
|
|
1073
|
-
best_thresholds = best_score_overall["THRESHOLDS"]
|
|
1073
|
+
best_thresholds = ast.literal_eval(best_score_overall["THRESHOLDS"])
|
|
1074
1074
|
joblib.dump(best_thresholds, f"{self.target_dir}/thresholds.pkl")
|
|
1075
1075
|
else:
|
|
1076
1076
|
best_thresholds = None
|
|
@@ -1852,7 +1852,9 @@ def apply_thresholds(
|
|
|
1852
1852
|
"""
|
|
1853
1853
|
|
|
1854
1854
|
# Case 1: Per-class thresholds
|
|
1855
|
-
if isinstance(threshold,
|
|
1855
|
+
if not isinstance(threshold, int):
|
|
1856
|
+
if isinstance(threshold, str):
|
|
1857
|
+
threshold = ast.literal_eval(threshold)
|
|
1856
1858
|
class_predictions = []
|
|
1857
1859
|
class_probabilities = []
|
|
1858
1860
|
|
|
@@ -1862,6 +1864,7 @@ def apply_thresholds(
|
|
|
1862
1864
|
metrics.get("threshold") if isinstance(metrics, dict) else metrics[0]
|
|
1863
1865
|
)
|
|
1864
1866
|
if _threshold is not None:
|
|
1867
|
+
class_label = int(class_label)
|
|
1865
1868
|
if class_label not in pred_proba.columns:
|
|
1866
1869
|
continue # skip missing class
|
|
1867
1870
|
col = pred_proba[class_label]
|
|
@@ -13,7 +13,7 @@ lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_mod
|
|
|
13
13
|
lecrapaud/db/alembic.ini,sha256=Zw2rdwsKV6c7J1SPtoFIPDX08_oTP3MuUKnNxBDiY8I,3796
|
|
14
14
|
lecrapaud/db/models/__init__.py,sha256=Lhyw9fVLdom0Fc6yIP-ip8FjkU1EwVwjae5q2VM815Q,740
|
|
15
15
|
lecrapaud/db/models/base.py,sha256=J9ew-0z_-tnWAwhVvOmVDys2R6jPF_oSca_ny6wpXQE,7606
|
|
16
|
-
lecrapaud/db/models/experiment.py,sha256=
|
|
16
|
+
lecrapaud/db/models/experiment.py,sha256=LjsMTY-PA9HZ27D2sz2fWy7HvwFqiS0dXKaiKF-S3k4,14868
|
|
17
17
|
lecrapaud/db/models/feature.py,sha256=5o77O2FyRObnLOCGNj8kaPSGM3pLv1Ov6mXXHYkmnYY,1136
|
|
18
18
|
lecrapaud/db/models/feature_selection.py,sha256=mk42xuw1Sm_7Pznfg7TNc5_S4hscdw79QgIe3Bt9ZRI,3245
|
|
19
19
|
lecrapaud/db/models/feature_selection_rank.py,sha256=Ydsb_rAT58FoSH13wkGjGPByzsjPx3DITXgJ2jgZmow,2198
|
|
@@ -26,7 +26,7 @@ lecrapaud/db/models/utils.py,sha256=-a-nWWmpJ2XzidIxo2COVUTrGZIPYCfBzjhcszJj_bM,
|
|
|
26
26
|
lecrapaud/db/session.py,sha256=E93WXcFFILFAIeH61ft2Egs7D-6caqs0oi4zCkO5Lq4,2822
|
|
27
27
|
lecrapaud/directories.py,sha256=0LrANuDgbuneSLker60c6q2hmGnQ3mKHIztTGzTx6Gw,826
|
|
28
28
|
lecrapaud/experiment.py,sha256=1xLWjOrqAxJh9CdXOx9ppQuRFRRj0GH-xYZqg-ty9hI,2463
|
|
29
|
-
lecrapaud/feature_engineering.py,sha256=
|
|
29
|
+
lecrapaud/feature_engineering.py,sha256=ib1afBrwqePiXUaw0Cpe6hY3VNl5afg8YVntb88SCT4,39199
|
|
30
30
|
lecrapaud/feature_selection.py,sha256=6ry-oVPQHbipm1XSE5YsH7AY0lQFt4CFbWiHiRs1nxg,43593
|
|
31
31
|
lecrapaud/integrations/openai_integration.py,sha256=hHLF3fk5Bps8KNbNrEL3NUFa945jwClE6LrLpuMZOd4,7459
|
|
32
32
|
lecrapaud/jobs/__init__.py,sha256=ZkrsyTOR21c_wN7RY8jPhm8jCrL1oCEtTsf3VFIlQiE,292
|
|
@@ -37,10 +37,10 @@ lecrapaud/misc/tabpfn_tests.ipynb,sha256=VkgsCUJ30d8jaL2VaWtQAgb8ngHPNtPgnXLs7QQ
|
|
|
37
37
|
lecrapaud/misc/test-gpu-bilstm.ipynb,sha256=4nLuZRJVe2kn6kEmauhRiz5wkWT9AVrYhI9CEk_dYUY,9608
|
|
38
38
|
lecrapaud/misc/test-gpu-resnet.ipynb,sha256=27Vu7nYwujYeh3fOxBNCnKJn3MXNPKZU-U8oDDUbymg,4944
|
|
39
39
|
lecrapaud/misc/test-gpu-transformers.ipynb,sha256=k6MBSs_Um1h4PykvE-LTBcdpbWLbIFST_xl_AFW2jgI,8444
|
|
40
|
-
lecrapaud/model_selection.py,sha256=
|
|
40
|
+
lecrapaud/model_selection.py,sha256=WbFn4wiykD8DOJ_7OsZLoocp-q4GDzW0dXCf-hHhl74,72471
|
|
41
41
|
lecrapaud/search_space.py,sha256=-JkzuMhaomdwiWi4HvVQY5hiw3-oREemJA16tbwEIp4,34854
|
|
42
42
|
lecrapaud/utils.py,sha256=eMnNVKWTqzXCLaaxSbKLBrThkOWoJrieifr9PNqFD5Y,8375
|
|
43
|
-
lecrapaud-0.18.
|
|
44
|
-
lecrapaud-0.18.
|
|
45
|
-
lecrapaud-0.18.
|
|
46
|
-
lecrapaud-0.18.
|
|
43
|
+
lecrapaud-0.18.4.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
|
|
44
|
+
lecrapaud-0.18.4.dist-info/METADATA,sha256=R9NN1DuZMKM9r4Z51Wy2lpaRL6ZAJiRDQ7ksgYt4hi4,11081
|
|
45
|
+
lecrapaud-0.18.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
46
|
+
lecrapaud-0.18.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|