lecrapaud 0.16.3__py3-none-any.whl → 0.16.5__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/config.py CHANGED
@@ -25,7 +25,7 @@ DB_PORT = (
25
25
  DB_NAME = (
26
26
  os.getenv("TEST_DB_NAME") if PYTHON_ENV == "Test" else os.getenv("DB_NAME", None)
27
27
  )
28
- DB_URI = (
28
+ DB_URI: str = (
29
29
  os.getenv("TEST_DB_URI", None)
30
30
  if PYTHON_ENV == "Test"
31
31
  else os.getenv("DB_URI", None)
lecrapaud/db/alembic.ini CHANGED
@@ -82,7 +82,7 @@ sqlalchemy.url = %(DATABASE_URL)s
82
82
 
83
83
  # Logging configuration
84
84
  [loggers]
85
- keys = root,sqlalchemy,alembic
85
+ keys = root,sqlalchemy,alembic,lecrapaud
86
86
 
87
87
  [loggers_root]
88
88
  disable_existing_loggers = False
@@ -108,6 +108,12 @@ level = INFO
108
108
  handlers =
109
109
  qualname = alembic
110
110
 
111
+ [logger_lecrapaud]
112
+ level = INFO
113
+ handlers = console
114
+ qualname = lecrapaud
115
+ propagate = 0
116
+
111
117
  [handler_console]
112
118
  class = StreamHandler
113
119
  args = (sys.stderr,)
@@ -241,7 +241,7 @@ class Experiment(Base):
241
241
  # This ensures we're comparing apples to apples by normalizing the scores
242
242
  experiments = db.query(cls).filter(cls.name.ilike(f"%{name}%")).all()
243
243
  if not experiments:
244
- return None
244
+ raise ValueError(f"No experiments found with the given name: {name}")
245
245
 
246
246
  # Get all scores
247
247
  rmse_scores = [e.avg_rmse for e in experiments if e.avg_rmse is not None]
@@ -250,7 +250,9 @@ class Experiment(Base):
250
250
  ]
251
251
 
252
252
  if not rmse_scores or not logloss_scores:
253
- return None
253
+ raise ValueError(
254
+ "No experiments found with both RMSE and LogLoss scores. Maybe try with only one metric."
255
+ )
254
256
 
255
257
  # Normalize scores (subtract min and divide by range)
256
258
  min_rmse = min(rmse_scores)
@@ -277,17 +279,29 @@ class Experiment(Base):
277
279
 
278
280
  return experiment_scores[0][0] if experiment_scores else None
279
281
 
280
- # For single metric case (rmse or logloss)
281
- score_property = cls.avg_rmse if metric == "rmse" else cls.avg_logloss
282
+ elif metric == "rmse" or metric == "logloss":
283
+ # For single metric case (rmse or logloss)
284
+ # Need to get all experiments first to evaluate instance properties
285
+ experiments = db.query(cls).filter(cls.name.ilike(f"%{name}%")).all()
282
286
 
283
- return (
284
- db.query(cls)
285
- .filter(
286
- cls.name.ilike(f"%{name}%"), score_property.isnot(None)
287
- ) # Only consider experiments with scores
288
- .order_by(score_property)
289
- .first()
290
- )
287
+ if not experiments:
288
+ return None
289
+
290
+ # Filter out experiments without scores and sort by the selected metric
291
+ filtered_experiments = []
292
+ for exp in experiments:
293
+ score = exp.avg_rmse if metric == "rmse" else exp.avg_logloss
294
+ if score is not None:
295
+ filtered_experiments.append((exp, score))
296
+
297
+ if not filtered_experiments:
298
+ return None
299
+
300
+ # Sort by score (ascending since lower is better)
301
+ filtered_experiments.sort(key=lambda x: x[1])
302
+ return filtered_experiments[0][0]
303
+ else:
304
+ raise ValueError("Invalid metric. Must be 'rmse', 'logloss', or 'both'.")
291
305
 
292
306
  def get_features(self, target_number: int):
293
307
  targets = [t for t in self.targets if t.name == f"TARGET_{target_number}"]
lecrapaud/db/session.py CHANGED
@@ -13,6 +13,8 @@ from lecrapaud.config import DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, DB
13
13
  _engine = None
14
14
  _SessionLocal = None
15
15
  if DB_URI:
16
+ if "mysql://" in DB_URI:
17
+ DB_URI = DB_URI.replace("mysql://", "mysql+pymysql://")
16
18
  DATABASE_URL = DB_URI
17
19
  elif DB_USER:
18
20
  DATABASE_URL = (
@@ -23,15 +25,13 @@ else:
23
25
 
24
26
 
25
27
  def init_db(uri: str = None):
26
- global _engine, _SessionLocal, DATABASE_URL
28
+ global _engine, _SessionLocal, DATABASE_URL, DB_URI
27
29
  if uri:
30
+ if "mysql://" in uri:
31
+ uri = uri.replace("mysql://", "mysql+pymysql://")
28
32
  DATABASE_URL = uri
29
- elif DB_USER:
30
- DATABASE_URL = (
31
- f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
32
- )
33
- elif DB_URI:
34
- DATABASE_URL = DB_URI
33
+ elif DATABASE_URL:
34
+ pass
35
35
  else:
36
36
  raise ValueError(
37
37
  "No database configuration found, please set env variables "
@@ -1253,7 +1253,7 @@ class ModelSelectionEngine:
1253
1253
  try:
1254
1254
  with open(best_params_file, "r") as f:
1255
1255
  target_params = json.load(f)
1256
- all_best_params[target_number] = target_params
1256
+ all_best_params[int(target_number)] = target_params
1257
1257
  except Exception as e:
1258
1258
  logger.warning(
1259
1259
  f"Error loading best params for {target_dir}: {str(e)}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lecrapaud
3
- Version: 0.16.3
3
+ Version: 0.16.5
4
4
  Summary: Framework for machine and deep learning, with regression, classification and time series analysis
5
5
  License: Apache License
6
6
  Author: Pierre H. Gallet
@@ -1,6 +1,6 @@
1
1
  lecrapaud/__init__.py,sha256=oCxbtw_nk8rlOXbXbWo0RRMlsh6w-hTiZ6e5PRG_wp0,28
2
2
  lecrapaud/api.py,sha256=qPswq6faq3bhCmcFUqukQesS3BGlXL35fPbeqlpx6ng,20300
3
- lecrapaud/config.py,sha256=N8kQS1bNEXp6loIw7_X2_OjrbY4_a7UZhZcT1XgsYAs,1121
3
+ lecrapaud/config.py,sha256=itiqC31HB8i2Xo-kn2viCQrg_9tnA07-TJuZ-xdnx44,1126
4
4
  lecrapaud/db/__init__.py,sha256=82o9fMfaqKXPh2_rt44EzNRVZV1R4LScEnQYvj_TjK0,34
5
5
  lecrapaud/db/alembic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
6
6
  lecrapaud/db/alembic/env.py,sha256=RvTTBa3bDVBxmDtapAfzUoeWBgmVQU3s9U6HmQCAP84,2421
@@ -9,10 +9,10 @@ lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py,sha256=hyPW0Mt_B4
9
9
  lecrapaud/db/alembic/versions/2025_06_24_1216-c62251b129ed_.py,sha256=6Pf36HAXEVrVlnrohAe2O7gVaXpDiv3LLIP_EEgTyA0,917
10
10
  lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py,sha256=KjwjYvFaNqYmBLTYel8As37fyaBtNVWTqN_3M7y_2eI,1357
11
11
  lecrapaud/db/alembic/versions/2025_06_25_1759-72aa496ca65b_.py,sha256=MiqooJuZ1etExl2he3MniaEv8G0LrmqY-0m22m9xKmc,943
12
- lecrapaud/db/alembic.ini,sha256=TXrZB4pWVLn2EUg867yp6paA_19vGeirO95mTPA3nbs,3699
12
+ lecrapaud/db/alembic.ini,sha256=Zw2rdwsKV6c7J1SPtoFIPDX08_oTP3MuUKnNxBDiY8I,3796
13
13
  lecrapaud/db/models/__init__.py,sha256=Lhyw9fVLdom0Fc6yIP-ip8FjkU1EwVwjae5q2VM815Q,740
14
14
  lecrapaud/db/models/base.py,sha256=J9ew-0z_-tnWAwhVvOmVDys2R6jPF_oSca_ny6wpXQE,7606
15
- lecrapaud/db/models/experiment.py,sha256=mQmbp_LzwMYVLzwYlaoRWYgzZCSJCA9dDcLpuvddsms,10931
15
+ lecrapaud/db/models/experiment.py,sha256=q5jJ5FZM-XONVQjj2l7s2Sx2KcxlD2KjmqYzvem9Z24,11738
16
16
  lecrapaud/db/models/feature.py,sha256=5o77O2FyRObnLOCGNj8kaPSGM3pLv1Ov6mXXHYkmnYY,1136
17
17
  lecrapaud/db/models/feature_selection.py,sha256=mk42xuw1Sm_7Pznfg7TNc5_S4hscdw79QgIe3Bt9ZRI,3245
18
18
  lecrapaud/db/models/feature_selection_rank.py,sha256=Ydsb_rAT58FoSH13wkGjGPByzsjPx3DITXgJ2jgZmow,2198
@@ -22,7 +22,7 @@ lecrapaud/db/models/model_training.py,sha256=jAIYPdwBln2jf593soLQ730uYrTfNK8zdG8
22
22
  lecrapaud/db/models/score.py,sha256=fSfXLt6Dm-8Fy9ku0urMT5Fa6zNqn4YqVnEO4o3zKVI,1669
23
23
  lecrapaud/db/models/target.py,sha256=DKnfeaLU8eT8J_oh_vuFo5-o1CaoXR13xBbswme6Bgk,1649
24
24
  lecrapaud/db/models/utils.py,sha256=-a-nWWmpJ2XzidIxo2COVUTrGZIPYCfBzjhcszJj_bM,1109
25
- lecrapaud/db/session.py,sha256=K9dTyXmO-aF_2r9RRHsDsbW9_zLNDaOcchXlpiv7cSo,2719
25
+ lecrapaud/db/session.py,sha256=NPa7A_uOaE4YegMYru2AwNk_kxg6rAZb0b-wqfWOjeY,2763
26
26
  lecrapaud/directories.py,sha256=0LrANuDgbuneSLker60c6q2hmGnQ3mKHIztTGzTx6Gw,826
27
27
  lecrapaud/experiment.py,sha256=1xLWjOrqAxJh9CdXOx9ppQuRFRRj0GH-xYZqg-ty9hI,2463
28
28
  lecrapaud/feature_engineering.py,sha256=2HaWn5UnZzczJBo7EyY1m1SGPmI6TpGXcwF58h_9wBE,32580
@@ -36,10 +36,10 @@ lecrapaud/misc/tabpfn_tests.ipynb,sha256=VkgsCUJ30d8jaL2VaWtQAgb8ngHPNtPgnXLs7QQ
36
36
  lecrapaud/misc/test-gpu-bilstm.ipynb,sha256=4nLuZRJVe2kn6kEmauhRiz5wkWT9AVrYhI9CEk_dYUY,9608
37
37
  lecrapaud/misc/test-gpu-resnet.ipynb,sha256=27Vu7nYwujYeh3fOxBNCnKJn3MXNPKZU-U8oDDUbymg,4944
38
38
  lecrapaud/misc/test-gpu-transformers.ipynb,sha256=k6MBSs_Um1h4PykvE-LTBcdpbWLbIFST_xl_AFW2jgI,8444
39
- lecrapaud/model_selection.py,sha256=l3ClaTeoz9wQak7nah3wsA_rlu7R1OChUAUk-ce5MjU,68509
39
+ lecrapaud/model_selection.py,sha256=tjBM9X5CP02pNiuNLdNK2MFZblrH7w-gQgBc5FEN-TY,68514
40
40
  lecrapaud/search_space.py,sha256=-JkzuMhaomdwiWi4HvVQY5hiw3-oREemJA16tbwEIp4,34854
41
41
  lecrapaud/utils.py,sha256=JdBB1NvbNIx4y0Una-kSZdo1_ZEocc5hwyYFIZKHmGg,8305
42
- lecrapaud-0.16.3.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
43
- lecrapaud-0.16.3.dist-info/METADATA,sha256=UvUfHYr9HNMOluhg9QNbdcFZ9f_I_cwT2Fk5kkAPP_8,11081
44
- lecrapaud-0.16.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
45
- lecrapaud-0.16.3.dist-info/RECORD,,
42
+ lecrapaud-0.16.5.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
43
+ lecrapaud-0.16.5.dist-info/METADATA,sha256=QLHyo-W9PTm_-_We0bNDLgPdgXGy-KrgJOX-UhtZ39s,11081
44
+ lecrapaud-0.16.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
45
+ lecrapaud-0.16.5.dist-info/RECORD,,