lecrapaud 0.14.4__tar.gz → 0.14.6__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.

Potentially problematic release.


This version of lecrapaud might be problematic. Click here for more details.

Files changed (47) hide show
  1. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/PKG-INFO +1 -1
  2. lecrapaud-0.14.6/lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py +449 -0
  3. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic/versions/2025_06_24_1216-c62251b129ed_.py +9 -4
  4. lecrapaud-0.14.6/lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py +45 -0
  5. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic/versions/2025_06_25_1759-72aa496ca65b_.py +9 -4
  6. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/experiment.py +7 -16
  7. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/feature_selection.py +7 -18
  8. lecrapaud-0.14.6/lecrapaud/db/models/utils.py +32 -0
  9. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/feature_engineering.py +7 -1
  10. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/model_selection.py +7 -5
  11. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/pyproject.toml +1 -1
  12. lecrapaud-0.14.4/lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py +0 -214
  13. lecrapaud-0.14.4/lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py +0 -34
  14. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/LICENSE +0 -0
  15. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/README.md +0 -0
  16. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/__init__.py +0 -0
  17. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/api.py +0 -0
  18. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/config.py +0 -0
  19. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/__init__.py +0 -0
  20. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic/README +0 -0
  21. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic/env.py +0 -0
  22. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic/script.py.mako +0 -0
  23. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/alembic.ini +0 -0
  24. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/__init__.py +0 -0
  25. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/base.py +0 -0
  26. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/feature.py +0 -0
  27. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/feature_selection_rank.py +0 -0
  28. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/model.py +0 -0
  29. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/model_selection.py +0 -0
  30. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/model_training.py +0 -0
  31. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/score.py +0 -0
  32. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/models/target.py +0 -0
  33. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/db/session.py +0 -0
  34. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/directories.py +0 -0
  35. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/experiment.py +0 -0
  36. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/feature_selection.py +0 -0
  37. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/integrations/openai_integration.py +0 -0
  38. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/jobs/__init__.py +0 -0
  39. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/jobs/config.py +0 -0
  40. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/jobs/scheduler.py +0 -0
  41. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/jobs/tasks.py +0 -0
  42. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/misc/tabpfn_tests.ipynb +0 -0
  43. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/misc/test-gpu-bilstm.ipynb +0 -0
  44. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/misc/test-gpu-resnet.ipynb +0 -0
  45. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/misc/test-gpu-transformers.ipynb +0 -0
  46. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/search_space.py +0 -0
  47. {lecrapaud-0.14.4 → lecrapaud-0.14.6}/lecrapaud/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lecrapaud
3
- Version: 0.14.4
3
+ Version: 0.14.6
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
@@ -0,0 +1,449 @@
1
+ """
2
+
3
+ Revision ID: f089dfb7e3ba
4
+ Revises:
5
+ Create Date: 2025-06-23 17:48:32.842030
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
14
+
15
+
16
+ # revision identifiers, used by Alembic.
17
+ revision: str = "f089dfb7e3ba"
18
+ down_revision: Union[str, None] = None
19
+ branch_labels: Union[str, Sequence[str], None] = None
20
+ depends_on: Union[str, Sequence[str], None] = None
21
+
22
+
23
+ def upgrade() -> None:
24
+ # ### commands auto generated by Alembic - please adjust! ###
25
+ op.create_table(
26
+ f"{LECRAPAUD_TABLE_PREFIX}_experiments",
27
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
28
+ sa.Column(
29
+ "created_at",
30
+ sa.TIMESTAMP(timezone=True),
31
+ server_default=sa.text("now()"),
32
+ nullable=False,
33
+ ),
34
+ sa.Column(
35
+ "updated_at",
36
+ sa.TIMESTAMP(timezone=True),
37
+ server_default=sa.text("now()"),
38
+ nullable=False,
39
+ ),
40
+ sa.Column("name", sa.String(length=50), nullable=False),
41
+ sa.Column("path", sa.String(length=255), nullable=True),
42
+ sa.Column("type", sa.String(length=50), nullable=False),
43
+ sa.Column("size", sa.Integer(), nullable=False),
44
+ sa.Column("train_size", sa.Integer(), nullable=True),
45
+ sa.Column("val_size", sa.Integer(), nullable=True),
46
+ sa.Column("test_size", sa.Integer(), nullable=True),
47
+ sa.Column("corr_threshold", sa.Float(), nullable=False),
48
+ sa.Column("max_features", sa.Integer(), nullable=False),
49
+ sa.Column("percentile", sa.Float(), nullable=False),
50
+ sa.Column("number_of_groups", sa.Integer(), nullable=True),
51
+ sa.Column("list_of_groups", sa.JSON(), nullable=True),
52
+ sa.Column("start_date", sa.DateTime(), nullable=True),
53
+ sa.Column("end_date", sa.DateTime(), nullable=True),
54
+ sa.Column("train_start_date", sa.DateTime(), nullable=True),
55
+ sa.Column("train_end_date", sa.DateTime(), nullable=True),
56
+ sa.Column("val_start_date", sa.DateTime(), nullable=True),
57
+ sa.Column("val_end_date", sa.DateTime(), nullable=True),
58
+ sa.Column("test_start_date", sa.DateTime(), nullable=True),
59
+ sa.Column("test_end_date", sa.DateTime(), nullable=True),
60
+ sa.PrimaryKeyConstraint("id"),
61
+ sa.UniqueConstraint("name", name="uq_experiments_composite"),
62
+ )
63
+ op.create_index(
64
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_experiments_id"),
65
+ f"{LECRAPAUD_TABLE_PREFIX}_experiments",
66
+ ["id"],
67
+ unique=False,
68
+ )
69
+ op.create_table(
70
+ f"{LECRAPAUD_TABLE_PREFIX}_features",
71
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
72
+ sa.Column(
73
+ "created_at",
74
+ sa.TIMESTAMP(timezone=True),
75
+ server_default=sa.text("now()"),
76
+ nullable=False,
77
+ ),
78
+ sa.Column(
79
+ "updated_at",
80
+ sa.TIMESTAMP(timezone=True),
81
+ server_default=sa.text("now()"),
82
+ nullable=False,
83
+ ),
84
+ sa.Column("name", sa.String(length=50), nullable=False),
85
+ sa.Column("type", sa.String(length=50), nullable=True),
86
+ sa.PrimaryKeyConstraint("id"),
87
+ sa.UniqueConstraint("name"),
88
+ )
89
+ op.create_index(
90
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_features_id"),
91
+ f"{LECRAPAUD_TABLE_PREFIX}_features",
92
+ ["id"],
93
+ unique=False,
94
+ )
95
+ op.create_table(
96
+ f"{LECRAPAUD_TABLE_PREFIX}_models",
97
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
98
+ sa.Column(
99
+ "created_at",
100
+ sa.TIMESTAMP(timezone=True),
101
+ server_default=sa.text("now()"),
102
+ nullable=False,
103
+ ),
104
+ sa.Column(
105
+ "updated_at",
106
+ sa.TIMESTAMP(timezone=True),
107
+ server_default=sa.text("now()"),
108
+ nullable=False,
109
+ ),
110
+ sa.Column("name", sa.String(length=50), nullable=False),
111
+ sa.Column("type", sa.String(length=50), nullable=False),
112
+ sa.PrimaryKeyConstraint("id"),
113
+ sa.UniqueConstraint("name", "type", name="uq_model_composite"),
114
+ )
115
+ op.create_index(
116
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_models_id"),
117
+ f"{LECRAPAUD_TABLE_PREFIX}_models",
118
+ ["id"],
119
+ unique=False,
120
+ )
121
+ op.create_table(
122
+ f"{LECRAPAUD_TABLE_PREFIX}_targets",
123
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
124
+ sa.Column(
125
+ "created_at",
126
+ sa.TIMESTAMP(timezone=True),
127
+ server_default=sa.text("now()"),
128
+ nullable=False,
129
+ ),
130
+ sa.Column(
131
+ "updated_at",
132
+ sa.TIMESTAMP(timezone=True),
133
+ server_default=sa.text("now()"),
134
+ nullable=False,
135
+ ),
136
+ sa.Column("name", sa.String(length=50), nullable=False),
137
+ sa.Column("type", sa.String(length=50), nullable=False),
138
+ sa.Column("description", sa.String(length=255), nullable=True),
139
+ sa.PrimaryKeyConstraint("id"),
140
+ sa.UniqueConstraint("name", "type", name="uq_target_composite"),
141
+ )
142
+ op.create_index(
143
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_targets_id"),
144
+ f"{LECRAPAUD_TABLE_PREFIX}_targets",
145
+ ["id"],
146
+ unique=False,
147
+ )
148
+ op.create_table(
149
+ f"{LECRAPAUD_TABLE_PREFIX}_experiment_target_association",
150
+ sa.Column("experiment_id", sa.BigInteger(), nullable=False),
151
+ sa.Column("target_id", sa.BigInteger(), nullable=False),
152
+ sa.ForeignKeyConstraint(
153
+ ["experiment_id"],
154
+ [f"{LECRAPAUD_TABLE_PREFIX}_experiments.id"],
155
+ ondelete="CASCADE",
156
+ ),
157
+ sa.ForeignKeyConstraint(
158
+ ["target_id"], [f"{LECRAPAUD_TABLE_PREFIX}_targets.id"], ondelete="CASCADE"
159
+ ),
160
+ sa.PrimaryKeyConstraint("experiment_id", "target_id"),
161
+ )
162
+ op.create_table(
163
+ f"{LECRAPAUD_TABLE_PREFIX}_feature_selections",
164
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
165
+ sa.Column(
166
+ "created_at",
167
+ sa.TIMESTAMP(timezone=True),
168
+ server_default=sa.text("now()"),
169
+ nullable=False,
170
+ ),
171
+ sa.Column(
172
+ "updated_at",
173
+ sa.TIMESTAMP(timezone=True),
174
+ server_default=sa.text("now()"),
175
+ nullable=False,
176
+ ),
177
+ sa.Column("training_time", sa.Integer(), nullable=True),
178
+ sa.Column("best_features_path", sa.String(length=255), nullable=True),
179
+ sa.Column("experiment_id", sa.BigInteger(), nullable=False),
180
+ sa.Column("target_id", sa.BigInteger(), nullable=False),
181
+ sa.ForeignKeyConstraint(
182
+ ["experiment_id"],
183
+ [f"{LECRAPAUD_TABLE_PREFIX}_experiments.id"],
184
+ ondelete="CASCADE",
185
+ ),
186
+ sa.ForeignKeyConstraint(
187
+ ["target_id"], [f"{LECRAPAUD_TABLE_PREFIX}_targets.id"], ondelete="CASCADE"
188
+ ),
189
+ sa.PrimaryKeyConstraint("id"),
190
+ sa.UniqueConstraint(
191
+ "experiment_id", "target_id", name="uq_feature_selection_composite"
192
+ ),
193
+ )
194
+ op.create_index(
195
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_feature_selections_id"),
196
+ f"{LECRAPAUD_TABLE_PREFIX}_feature_selections",
197
+ ["id"],
198
+ unique=False,
199
+ )
200
+ op.create_table(
201
+ f"{LECRAPAUD_TABLE_PREFIX}_model_selections",
202
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
203
+ sa.Column(
204
+ "created_at",
205
+ sa.TIMESTAMP(timezone=True),
206
+ server_default=sa.text("now()"),
207
+ nullable=False,
208
+ ),
209
+ sa.Column(
210
+ "updated_at",
211
+ sa.TIMESTAMP(timezone=True),
212
+ server_default=sa.text("now()"),
213
+ nullable=False,
214
+ ),
215
+ sa.Column("best_model_params", sa.JSON(), nullable=True),
216
+ sa.Column("best_model_path", sa.String(length=255), nullable=True),
217
+ sa.Column("best_model_id", sa.BigInteger(), nullable=True),
218
+ sa.Column("target_id", sa.BigInteger(), nullable=False),
219
+ sa.Column("experiment_id", sa.BigInteger(), nullable=False),
220
+ sa.ForeignKeyConstraint(
221
+ ["best_model_id"],
222
+ [f"{LECRAPAUD_TABLE_PREFIX}_models.id"],
223
+ ondelete="CASCADE",
224
+ ),
225
+ sa.ForeignKeyConstraint(
226
+ ["experiment_id"],
227
+ [f"{LECRAPAUD_TABLE_PREFIX}_experiments.id"],
228
+ ondelete="CASCADE",
229
+ ),
230
+ sa.ForeignKeyConstraint(
231
+ ["target_id"], [f"{LECRAPAUD_TABLE_PREFIX}_targets.id"], ondelete="CASCADE"
232
+ ),
233
+ sa.PrimaryKeyConstraint("id"),
234
+ sa.UniqueConstraint(
235
+ "target_id", "experiment_id", name="uq_model_selection_composite"
236
+ ),
237
+ )
238
+ op.create_index(
239
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_model_selections_id"),
240
+ f"{LECRAPAUD_TABLE_PREFIX}_model_selections",
241
+ ["id"],
242
+ unique=False,
243
+ )
244
+ op.create_table(
245
+ f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_association",
246
+ sa.Column("feature_selection_id", sa.BigInteger(), nullable=False),
247
+ sa.Column("feature_id", sa.BigInteger(), nullable=False),
248
+ sa.ForeignKeyConstraint(
249
+ ["feature_id"],
250
+ [f"{LECRAPAUD_TABLE_PREFIX}_features.id"],
251
+ ondelete="CASCADE",
252
+ ),
253
+ sa.ForeignKeyConstraint(
254
+ ["feature_selection_id"],
255
+ [f"{LECRAPAUD_TABLE_PREFIX}_feature_selections.id"],
256
+ ondelete="CASCADE",
257
+ ),
258
+ sa.PrimaryKeyConstraint("feature_selection_id", "feature_id"),
259
+ )
260
+ op.create_table(
261
+ f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks",
262
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
263
+ sa.Column(
264
+ "created_at",
265
+ sa.TIMESTAMP(timezone=True),
266
+ server_default=sa.text("now()"),
267
+ nullable=False,
268
+ ),
269
+ sa.Column(
270
+ "updated_at",
271
+ sa.TIMESTAMP(timezone=True),
272
+ server_default=sa.text("now()"),
273
+ nullable=False,
274
+ ),
275
+ sa.Column("score", sa.Float(), nullable=True),
276
+ sa.Column("pvalue", sa.Float(), nullable=True),
277
+ sa.Column("support", sa.Integer(), nullable=True),
278
+ sa.Column("rank", sa.Integer(), nullable=True),
279
+ sa.Column("method", sa.String(length=50), nullable=True),
280
+ sa.Column("training_time", sa.Integer(), nullable=True),
281
+ sa.Column("feature_id", sa.BigInteger(), nullable=True),
282
+ sa.Column("feature_selection_id", sa.BigInteger(), nullable=True),
283
+ sa.ForeignKeyConstraint(
284
+ ["feature_id"],
285
+ [f"{LECRAPAUD_TABLE_PREFIX}_features.id"],
286
+ ondelete="CASCADE",
287
+ ),
288
+ sa.ForeignKeyConstraint(
289
+ ["feature_selection_id"],
290
+ [f"{LECRAPAUD_TABLE_PREFIX}_feature_selections.id"],
291
+ ondelete="CASCADE",
292
+ ),
293
+ sa.PrimaryKeyConstraint("id"),
294
+ sa.UniqueConstraint(
295
+ "feature_id",
296
+ "feature_selection_id",
297
+ "method",
298
+ name="uq_feature_selection_rank_composite",
299
+ ),
300
+ )
301
+ op.create_index(
302
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks_id"),
303
+ f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks",
304
+ ["id"],
305
+ unique=False,
306
+ )
307
+ op.create_table(
308
+ f"{LECRAPAUD_TABLE_PREFIX}_model_trainings",
309
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
310
+ sa.Column(
311
+ "created_at",
312
+ sa.TIMESTAMP(timezone=True),
313
+ server_default=sa.text("now()"),
314
+ nullable=False,
315
+ ),
316
+ sa.Column(
317
+ "updated_at",
318
+ sa.TIMESTAMP(timezone=True),
319
+ server_default=sa.text("now()"),
320
+ nullable=False,
321
+ ),
322
+ sa.Column("best_params", sa.JSON(), nullable=True),
323
+ sa.Column("model_path", sa.String(length=255), nullable=True),
324
+ sa.Column("training_time", sa.Integer(), nullable=True),
325
+ sa.Column("model_id", sa.BigInteger(), nullable=False),
326
+ sa.Column("model_selection_id", sa.BigInteger(), nullable=False),
327
+ sa.ForeignKeyConstraint(
328
+ ["model_id"],
329
+ [f"{LECRAPAUD_TABLE_PREFIX}_models.id"],
330
+ ),
331
+ sa.ForeignKeyConstraint(
332
+ ["model_selection_id"],
333
+ [f"{LECRAPAUD_TABLE_PREFIX}_model_selections.id"],
334
+ ondelete="CASCADE",
335
+ ),
336
+ sa.PrimaryKeyConstraint("id"),
337
+ sa.UniqueConstraint(
338
+ "model_id", "model_selection_id", name="uq_model_training_composite"
339
+ ),
340
+ )
341
+ op.create_index(
342
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_model_trainings_id"),
343
+ f"{LECRAPAUD_TABLE_PREFIX}_model_trainings",
344
+ ["id"],
345
+ unique=False,
346
+ )
347
+ op.create_table(
348
+ f"{LECRAPAUD_TABLE_PREFIX}_scores",
349
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
350
+ sa.Column(
351
+ "created_at",
352
+ sa.TIMESTAMP(timezone=True),
353
+ server_default=sa.text("now()"),
354
+ nullable=False,
355
+ ),
356
+ sa.Column(
357
+ "updated_at",
358
+ sa.TIMESTAMP(timezone=True),
359
+ server_default=sa.text("now()"),
360
+ nullable=False,
361
+ ),
362
+ sa.Column("type", sa.String(length=50), nullable=False),
363
+ sa.Column("training_time", sa.Integer(), nullable=True),
364
+ sa.Column("eval_data_std", sa.Float(), nullable=True),
365
+ sa.Column("rmse", sa.Float(), nullable=True),
366
+ sa.Column("rmse_std_ratio", sa.Float(), nullable=True),
367
+ sa.Column("mae", sa.Float(), nullable=True),
368
+ sa.Column("mape", sa.Float(), nullable=True),
369
+ sa.Column("mam", sa.Float(), nullable=True),
370
+ sa.Column("mad", sa.Float(), nullable=True),
371
+ sa.Column("mae_mam_ratio", sa.Float(), nullable=True),
372
+ sa.Column("mae_mad_ratio", sa.Float(), nullable=True),
373
+ sa.Column("r2", sa.Float(), nullable=True),
374
+ sa.Column("logloss", sa.Float(), nullable=True),
375
+ sa.Column("accuracy", sa.Float(), nullable=True),
376
+ sa.Column("precision", sa.Float(), nullable=True),
377
+ sa.Column("recall", sa.Float(), nullable=True),
378
+ sa.Column("f1", sa.Float(), nullable=True),
379
+ sa.Column("roc_auc", sa.Float(), nullable=True),
380
+ sa.Column("threshold", sa.Float(), nullable=True),
381
+ sa.Column("precision_at_threshold", sa.Float(), nullable=True),
382
+ sa.Column("recall_at_threshold", sa.Float(), nullable=True),
383
+ sa.Column("model_training_id", sa.BigInteger(), nullable=False),
384
+ sa.ForeignKeyConstraint(
385
+ ["model_training_id"],
386
+ [f"{LECRAPAUD_TABLE_PREFIX}_model_trainings.id"],
387
+ ondelete="CASCADE",
388
+ ),
389
+ sa.PrimaryKeyConstraint("id"),
390
+ )
391
+ op.create_index(
392
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_scores_id"),
393
+ f"{LECRAPAUD_TABLE_PREFIX}_scores",
394
+ ["id"],
395
+ unique=False,
396
+ )
397
+ # ### end Alembic commands ###
398
+
399
+
400
+ def downgrade() -> None:
401
+ # ### commands auto generated by Alembic - please adjust! ###
402
+ op.drop_index(
403
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_scores_id"),
404
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_scores",
405
+ )
406
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_scores")
407
+ op.drop_index(
408
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_model_trainings_id"),
409
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_model_trainings",
410
+ )
411
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_model_trainings")
412
+ op.drop_index(
413
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks_id"),
414
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks",
415
+ )
416
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_ranks")
417
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_association")
418
+ op.drop_index(
419
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_model_selections_id"),
420
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_model_selections",
421
+ )
422
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_model_selections")
423
+ op.drop_index(
424
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_feature_selections_id"),
425
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_feature_selections",
426
+ )
427
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_feature_selections")
428
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_experiment_target_association")
429
+ op.drop_index(
430
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_targets_id"),
431
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_targets",
432
+ )
433
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_targets")
434
+ op.drop_index(
435
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_models_id"),
436
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_models",
437
+ )
438
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_models")
439
+ op.drop_index(
440
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_features_id"),
441
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_features",
442
+ )
443
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_features")
444
+ op.drop_index(
445
+ op.f(f"ix_{LECRAPAUD_TABLE_PREFIX}_experiments_id"),
446
+ table_name=f"{LECRAPAUD_TABLE_PREFIX}_experiments",
447
+ )
448
+ op.drop_table(f"{LECRAPAUD_TABLE_PREFIX}_experiments")
449
+ # ### end Alembic commands ###
@@ -5,26 +5,31 @@ Revises: f089dfb7e3ba
5
5
  Create Date: 2025-06-24 12:16:21.949079
6
6
 
7
7
  """
8
+
8
9
  from typing import Sequence, Union
9
10
 
10
11
  from alembic import op
11
12
  import sqlalchemy as sa
13
+ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
12
14
 
13
15
 
14
16
  # revision identifiers, used by Alembic.
15
- revision: str = 'c62251b129ed'
16
- down_revision: Union[str, None] = 'f089dfb7e3ba'
17
+ revision: str = "c62251b129ed"
18
+ down_revision: Union[str, None] = "f089dfb7e3ba"
17
19
  branch_labels: Union[str, Sequence[str], None] = None
18
20
  depends_on: Union[str, Sequence[str], None] = None
19
21
 
20
22
 
21
23
  def upgrade() -> None:
22
24
  # ### commands auto generated by Alembic - please adjust! ###
23
- op.add_column('lecrapaud_experiments', sa.Column('context', sa.JSON(), nullable=True))
25
+ op.add_column(
26
+ f"{LECRAPAUD_TABLE_PREFIX}_experiments",
27
+ sa.Column("context", sa.JSON(), nullable=True),
28
+ )
24
29
  # ### end Alembic commands ###
25
30
 
26
31
 
27
32
  def downgrade() -> None:
28
33
  # ### commands auto generated by Alembic - please adjust! ###
29
- op.drop_column('lecrapaud_experiments', 'context')
34
+ op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_experiments", "context")
30
35
  # ### end Alembic commands ###
@@ -0,0 +1,45 @@
1
+ """
2
+
3
+ Revision ID: 86457e2f333f
4
+ Revises: c62251b129ed
5
+ Create Date: 2025-06-24 17:11:25.187876
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from sqlalchemy.dialects import mysql
14
+ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
15
+
16
+ # revision identifiers, used by Alembic.
17
+ revision: str = "86457e2f333f"
18
+ down_revision: Union[str, None] = "c62251b129ed"
19
+ branch_labels: Union[str, Sequence[str], None] = None
20
+ depends_on: Union[str, Sequence[str], None] = None
21
+
22
+
23
+ def upgrade() -> None:
24
+ # ### commands auto generated by Alembic - please adjust! ###
25
+ op.add_column(
26
+ f"{LECRAPAUD_TABLE_PREFIX}_scores",
27
+ sa.Column("thresholds", sa.JSON(), nullable=True),
28
+ )
29
+ op.add_column(
30
+ f"{LECRAPAUD_TABLE_PREFIX}_scores",
31
+ sa.Column("f1_at_threshold", sa.Float(), nullable=True),
32
+ )
33
+ op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_scores", "threshold")
34
+ # ### end Alembic commands ###
35
+
36
+
37
+ def downgrade() -> None:
38
+ # ### commands auto generated by Alembic - please adjust! ###
39
+ op.add_column(
40
+ f"{LECRAPAUD_TABLE_PREFIX}_scores",
41
+ sa.Column("threshold", mysql.FLOAT(), nullable=True),
42
+ )
43
+ op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_scores", "f1_at_threshold")
44
+ op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_scores", "thresholds")
45
+ # ### end Alembic commands ###
@@ -5,26 +5,31 @@ Revises: 86457e2f333f
5
5
  Create Date: 2025-06-25 17:59:28.544283
6
6
 
7
7
  """
8
+
8
9
  from typing import Sequence, Union
9
10
 
10
11
  from alembic import op
11
12
  import sqlalchemy as sa
13
+ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
12
14
 
13
15
 
14
16
  # revision identifiers, used by Alembic.
15
- revision: str = '72aa496ca65b'
16
- down_revision: Union[str, None] = '86457e2f333f'
17
+ revision: str = "72aa496ca65b"
18
+ down_revision: Union[str, None] = "86457e2f333f"
17
19
  branch_labels: Union[str, Sequence[str], None] = None
18
20
  depends_on: Union[str, Sequence[str], None] = None
19
21
 
20
22
 
21
23
  def upgrade() -> None:
22
24
  # ### commands auto generated by Alembic - please adjust! ###
23
- op.add_column('lecrapaud_model_selections', sa.Column('best_thresholds', sa.JSON(), nullable=True))
25
+ op.add_column(
26
+ f"{LECRAPAUD_TABLE_PREFIX}_model_selections",
27
+ sa.Column("best_thresholds", sa.JSON(), nullable=True),
28
+ )
24
29
  # ### end Alembic commands ###
25
30
 
26
31
 
27
32
  def downgrade() -> None:
28
33
  # ### commands auto generated by Alembic - please adjust! ###
29
- op.drop_column('lecrapaud_model_selections', 'best_thresholds')
34
+ op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_model_selections", "best_thresholds")
30
35
  # ### end Alembic commands ###
@@ -18,24 +18,15 @@ from sqlalchemy import (
18
18
  from sqlalchemy.orm import relationship
19
19
 
20
20
  from lecrapaud.db.models.base import Base
21
- from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
21
+ from lecrapaud.db.models.utils import create_association_table
22
22
 
23
23
  # jointures
24
- lecrapaud_experiment_target_association = Table(
25
- f"{LECRAPAUD_TABLE_PREFIX}_experiment_target_association",
26
- Base.metadata,
27
- Column(
28
- "experiment_id",
29
- BigInteger,
30
- ForeignKey(f"{LECRAPAUD_TABLE_PREFIX}_experiments.id", ondelete="CASCADE"),
31
- primary_key=True,
32
- ),
33
- Column(
34
- "target_id",
35
- BigInteger,
36
- ForeignKey(f"{LECRAPAUD_TABLE_PREFIX}_targets.id", ondelete="CASCADE"),
37
- primary_key=True,
38
- ),
24
+ lecrapaud_experiment_target_association = create_association_table(
25
+ name="experiment_target_association",
26
+ table1="experiments",
27
+ column1="experiment",
28
+ table2="targets",
29
+ column2="target"
39
30
  )
40
31
 
41
32
 
@@ -26,26 +26,15 @@ from collections.abc import Iterable
26
26
 
27
27
  from lecrapaud.db.session import get_db
28
28
  from lecrapaud.db.models.base import Base, with_db
29
- from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
29
+ from lecrapaud.db.models.utils import create_association_table
30
30
 
31
31
  # jointures
32
- lecrapaud_feature_selection_association = Table(
33
- f"{LECRAPAUD_TABLE_PREFIX}_feature_selection_association",
34
- Base.metadata,
35
- Column(
36
- "feature_selection_id",
37
- BigInteger,
38
- ForeignKey(
39
- f"{LECRAPAUD_TABLE_PREFIX}_feature_selections.id", ondelete="CASCADE"
40
- ),
41
- primary_key=True,
42
- ),
43
- Column(
44
- "feature_id",
45
- BigInteger,
46
- ForeignKey(f"{LECRAPAUD_TABLE_PREFIX}_features.id", ondelete="CASCADE"),
47
- primary_key=True,
48
- ),
32
+ lecrapaud_feature_selection_association = create_association_table(
33
+ name="feature_selection_association",
34
+ table1="feature_selections",
35
+ column1="feature_selection",
36
+ table2="features",
37
+ column2="feature"
49
38
  )
50
39
 
51
40
 
@@ -0,0 +1,32 @@
1
+ from sqlalchemy import Table, Column, BigInteger, ForeignKey
2
+
3
+ from lecrapaud.db.models.base import Base
4
+ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
5
+
6
+
7
+ def create_association_table(name, table1, column1, table2, column2):
8
+ """Create an association table with the LECRAPAUD_TABLE_PREFIX.
9
+
10
+ Args:
11
+ name: The base name for the association table (will be prefixed)
12
+ table1: First table name (without prefix)
13
+ column1: First column name (will be used as f"{column1}_id")
14
+ table2: Second table name (without prefix)
15
+ column2: Second column name (will be used as f"{column2}_id")
16
+ """
17
+ return Table(
18
+ f"{LECRAPAUD_TABLE_PREFIX}_{name}",
19
+ Base.metadata,
20
+ Column(
21
+ f"{column1}_id",
22
+ BigInteger,
23
+ ForeignKey(f"{LECRAPAUD_TABLE_PREFIX}_{table1}.id", ondelete="CASCADE"),
24
+ primary_key=True,
25
+ ),
26
+ Column(
27
+ f"{column2}_id",
28
+ BigInteger,
29
+ ForeignKey(f"{LECRAPAUD_TABLE_PREFIX}_{table2}.id", ondelete="CASCADE"),
30
+ primary_key=True,
31
+ ),
32
+ )
@@ -380,10 +380,16 @@ class PreprocessFeature:
380
380
  summary = summarize_dataframe(train)
381
381
  summary.to_csv(f"{self.experiment_dir}/feature_summary.csv", index=False)
382
382
 
383
+ # Save all features before selection
384
+ joblib.dump(
385
+ train, f"{self.preprocessing_dir}/all_features_before_selection.pkl"
386
+ )
387
+
383
388
  return train, val, test
384
389
 
385
390
  def inference(self):
386
391
  data = self.data
392
+
387
393
  # PCA
388
394
  if os.path.exists(f"{self.preprocessing_dir}/pcas.pkl"):
389
395
  pcas = joblib.load(f"{self.preprocessing_dir}/pcas.pkl")
@@ -652,7 +658,7 @@ class PreprocessFeature:
652
658
  X_transformed = pd.DataFrame(transformed, columns=column_names, index=df.index)
653
659
 
654
660
  # Try to convert columns to best possible dtypes
655
- X_transformed = X_transformed.convert_dtypes()
661
+ X_transformed = X_transformed.convert_ups()
656
662
 
657
663
  # Insert features in db
658
664
  if save_in_db:
@@ -570,11 +570,13 @@ class ModelEngine:
570
570
  self.target_type = self._model.target_type
571
571
 
572
572
  # Load threshold
573
- self.threshold = (
574
- joblib.load(f"{self.path}/thresholds.pkl")
575
- if self.target_type == "classification"
576
- else None
577
- )
573
+ if (
574
+ os.path.exists(f"{self.path}/thresholds.pkl")
575
+ and self.target_type == "classification"
576
+ ):
577
+ self.threshold = joblib.load(f"{self.path}/thresholds.pkl")
578
+ else:
579
+ self.threshold = None
578
580
 
579
581
  logger.info(
580
582
  f"Loaded model {self._model.model_name} and threshold {self.threshold}"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lecrapaud"
3
- version = "0.14.4"
3
+ version = "0.14.6"
4
4
  description = "Framework for machine and deep learning, with regression, classification and time series analysis"
5
5
  authors = [
6
6
  {name = "Pierre H. Gallet"}
@@ -1,214 +0,0 @@
1
- """
2
-
3
- Revision ID: f089dfb7e3ba
4
- Revises:
5
- Create Date: 2025-06-23 17:48:32.842030
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
-
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = 'f089dfb7e3ba'
16
- down_revision: Union[str, None] = None
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # ### commands auto generated by Alembic - please adjust! ###
23
- op.create_table('lecrapaud_experiments',
24
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
25
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
26
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
27
- sa.Column('name', sa.String(length=50), nullable=False),
28
- sa.Column('path', sa.String(length=255), nullable=True),
29
- sa.Column('type', sa.String(length=50), nullable=False),
30
- sa.Column('size', sa.Integer(), nullable=False),
31
- sa.Column('train_size', sa.Integer(), nullable=True),
32
- sa.Column('val_size', sa.Integer(), nullable=True),
33
- sa.Column('test_size', sa.Integer(), nullable=True),
34
- sa.Column('corr_threshold', sa.Float(), nullable=False),
35
- sa.Column('max_features', sa.Integer(), nullable=False),
36
- sa.Column('percentile', sa.Float(), nullable=False),
37
- sa.Column('number_of_groups', sa.Integer(), nullable=True),
38
- sa.Column('list_of_groups', sa.JSON(), nullable=True),
39
- sa.Column('start_date', sa.DateTime(), nullable=True),
40
- sa.Column('end_date', sa.DateTime(), nullable=True),
41
- sa.Column('train_start_date', sa.DateTime(), nullable=True),
42
- sa.Column('train_end_date', sa.DateTime(), nullable=True),
43
- sa.Column('val_start_date', sa.DateTime(), nullable=True),
44
- sa.Column('val_end_date', sa.DateTime(), nullable=True),
45
- sa.Column('test_start_date', sa.DateTime(), nullable=True),
46
- sa.Column('test_end_date', sa.DateTime(), nullable=True),
47
- sa.PrimaryKeyConstraint('id'),
48
- sa.UniqueConstraint('name', name='uq_experiments_composite')
49
- )
50
- op.create_index(op.f('ix_lecrapaud_experiments_id'), 'lecrapaud_experiments', ['id'], unique=False)
51
- op.create_table('lecrapaud_features',
52
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
53
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
54
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
55
- sa.Column('name', sa.String(length=50), nullable=False),
56
- sa.Column('type', sa.String(length=50), nullable=True),
57
- sa.PrimaryKeyConstraint('id'),
58
- sa.UniqueConstraint('name')
59
- )
60
- op.create_index(op.f('ix_lecrapaud_features_id'), 'lecrapaud_features', ['id'], unique=False)
61
- op.create_table('lecrapaud_models',
62
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
63
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
64
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
65
- sa.Column('name', sa.String(length=50), nullable=False),
66
- sa.Column('type', sa.String(length=50), nullable=False),
67
- sa.PrimaryKeyConstraint('id'),
68
- sa.UniqueConstraint('name', 'type', name='uq_model_composite')
69
- )
70
- op.create_index(op.f('ix_lecrapaud_models_id'), 'lecrapaud_models', ['id'], unique=False)
71
- op.create_table('lecrapaud_targets',
72
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
73
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
74
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
75
- sa.Column('name', sa.String(length=50), nullable=False),
76
- sa.Column('type', sa.String(length=50), nullable=False),
77
- sa.Column('description', sa.String(length=255), nullable=True),
78
- sa.PrimaryKeyConstraint('id'),
79
- sa.UniqueConstraint('name', 'type', name='uq_target_composite')
80
- )
81
- op.create_index(op.f('ix_lecrapaud_targets_id'), 'lecrapaud_targets', ['id'], unique=False)
82
- op.create_table('lecrapaud_experiment_target_association',
83
- sa.Column('experiment_id', sa.BigInteger(), nullable=False),
84
- sa.Column('target_id', sa.BigInteger(), nullable=False),
85
- sa.ForeignKeyConstraint(['experiment_id'], ['lecrapaud_experiments.id'], ondelete='CASCADE'),
86
- sa.ForeignKeyConstraint(['target_id'], ['lecrapaud_targets.id'], ondelete='CASCADE'),
87
- sa.PrimaryKeyConstraint('experiment_id', 'target_id')
88
- )
89
- op.create_table('lecrapaud_feature_selections',
90
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
91
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
92
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
93
- sa.Column('training_time', sa.Integer(), nullable=True),
94
- sa.Column('best_features_path', sa.String(length=255), nullable=True),
95
- sa.Column('experiment_id', sa.BigInteger(), nullable=False),
96
- sa.Column('target_id', sa.BigInteger(), nullable=False),
97
- sa.ForeignKeyConstraint(['experiment_id'], ['lecrapaud_experiments.id'], ondelete='CASCADE'),
98
- sa.ForeignKeyConstraint(['target_id'], ['lecrapaud_targets.id'], ondelete='CASCADE'),
99
- sa.PrimaryKeyConstraint('id'),
100
- sa.UniqueConstraint('experiment_id', 'target_id', name='uq_feature_selection_composite')
101
- )
102
- op.create_index(op.f('ix_lecrapaud_feature_selections_id'), 'lecrapaud_feature_selections', ['id'], unique=False)
103
- op.create_table('lecrapaud_model_selections',
104
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
105
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
106
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
107
- sa.Column('best_model_params', sa.JSON(), nullable=True),
108
- sa.Column('best_model_path', sa.String(length=255), nullable=True),
109
- sa.Column('best_model_id', sa.BigInteger(), nullable=True),
110
- sa.Column('target_id', sa.BigInteger(), nullable=False),
111
- sa.Column('experiment_id', sa.BigInteger(), nullable=False),
112
- sa.ForeignKeyConstraint(['best_model_id'], ['lecrapaud_models.id'], ondelete='CASCADE'),
113
- sa.ForeignKeyConstraint(['experiment_id'], ['lecrapaud_experiments.id'], ondelete='CASCADE'),
114
- sa.ForeignKeyConstraint(['target_id'], ['lecrapaud_targets.id'], ondelete='CASCADE'),
115
- sa.PrimaryKeyConstraint('id'),
116
- sa.UniqueConstraint('target_id', 'experiment_id', name='uq_model_selection_composite')
117
- )
118
- op.create_index(op.f('ix_lecrapaud_model_selections_id'), 'lecrapaud_model_selections', ['id'], unique=False)
119
- op.create_table('lecrapaud_feature_selection_association',
120
- sa.Column('feature_selection_id', sa.BigInteger(), nullable=False),
121
- sa.Column('feature_id', sa.BigInteger(), nullable=False),
122
- sa.ForeignKeyConstraint(['feature_id'], ['lecrapaud_features.id'], ondelete='CASCADE'),
123
- sa.ForeignKeyConstraint(['feature_selection_id'], ['lecrapaud_feature_selections.id'], ondelete='CASCADE'),
124
- sa.PrimaryKeyConstraint('feature_selection_id', 'feature_id')
125
- )
126
- op.create_table('lecrapaud_feature_selection_ranks',
127
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
128
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
129
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
130
- sa.Column('score', sa.Float(), nullable=True),
131
- sa.Column('pvalue', sa.Float(), nullable=True),
132
- sa.Column('support', sa.Integer(), nullable=True),
133
- sa.Column('rank', sa.Integer(), nullable=True),
134
- sa.Column('method', sa.String(length=50), nullable=True),
135
- sa.Column('training_time', sa.Integer(), nullable=True),
136
- sa.Column('feature_id', sa.BigInteger(), nullable=True),
137
- sa.Column('feature_selection_id', sa.BigInteger(), nullable=True),
138
- sa.ForeignKeyConstraint(['feature_id'], ['lecrapaud_features.id'], ondelete='CASCADE'),
139
- sa.ForeignKeyConstraint(['feature_selection_id'], ['lecrapaud_feature_selections.id'], ondelete='CASCADE'),
140
- sa.PrimaryKeyConstraint('id'),
141
- sa.UniqueConstraint('feature_id', 'feature_selection_id', 'method', name='uq_feature_selection_rank_composite')
142
- )
143
- op.create_index(op.f('ix_lecrapaud_feature_selection_ranks_id'), 'lecrapaud_feature_selection_ranks', ['id'], unique=False)
144
- op.create_table('lecrapaud_model_trainings',
145
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
146
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
147
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
148
- sa.Column('best_params', sa.JSON(), nullable=True),
149
- sa.Column('model_path', sa.String(length=255), nullable=True),
150
- sa.Column('training_time', sa.Integer(), nullable=True),
151
- sa.Column('model_id', sa.BigInteger(), nullable=False),
152
- sa.Column('model_selection_id', sa.BigInteger(), nullable=False),
153
- sa.ForeignKeyConstraint(['model_id'], ['lecrapaud_models.id'], ),
154
- sa.ForeignKeyConstraint(['model_selection_id'], ['lecrapaud_model_selections.id'], ondelete='CASCADE'),
155
- sa.PrimaryKeyConstraint('id'),
156
- sa.UniqueConstraint('model_id', 'model_selection_id', name='uq_model_training_composite')
157
- )
158
- op.create_index(op.f('ix_lecrapaud_model_trainings_id'), 'lecrapaud_model_trainings', ['id'], unique=False)
159
- op.create_table('lecrapaud_scores',
160
- sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
161
- sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
162
- sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
163
- sa.Column('type', sa.String(length=50), nullable=False),
164
- sa.Column('training_time', sa.Integer(), nullable=True),
165
- sa.Column('eval_data_std', sa.Float(), nullable=True),
166
- sa.Column('rmse', sa.Float(), nullable=True),
167
- sa.Column('rmse_std_ratio', sa.Float(), nullable=True),
168
- sa.Column('mae', sa.Float(), nullable=True),
169
- sa.Column('mape', sa.Float(), nullable=True),
170
- sa.Column('mam', sa.Float(), nullable=True),
171
- sa.Column('mad', sa.Float(), nullable=True),
172
- sa.Column('mae_mam_ratio', sa.Float(), nullable=True),
173
- sa.Column('mae_mad_ratio', sa.Float(), nullable=True),
174
- sa.Column('r2', sa.Float(), nullable=True),
175
- sa.Column('logloss', sa.Float(), nullable=True),
176
- sa.Column('accuracy', sa.Float(), nullable=True),
177
- sa.Column('precision', sa.Float(), nullable=True),
178
- sa.Column('recall', sa.Float(), nullable=True),
179
- sa.Column('f1', sa.Float(), nullable=True),
180
- sa.Column('roc_auc', sa.Float(), nullable=True),
181
- sa.Column('threshold', sa.Float(), nullable=True),
182
- sa.Column('precision_at_threshold', sa.Float(), nullable=True),
183
- sa.Column('recall_at_threshold', sa.Float(), nullable=True),
184
- sa.Column('model_training_id', sa.BigInteger(), nullable=False),
185
- sa.ForeignKeyConstraint(['model_training_id'], ['lecrapaud_model_trainings.id'], ondelete='CASCADE'),
186
- sa.PrimaryKeyConstraint('id')
187
- )
188
- op.create_index(op.f('ix_lecrapaud_scores_id'), 'lecrapaud_scores', ['id'], unique=False)
189
- # ### end Alembic commands ###
190
-
191
-
192
- def downgrade() -> None:
193
- # ### commands auto generated by Alembic - please adjust! ###
194
- op.drop_index(op.f('ix_lecrapaud_scores_id'), table_name='lecrapaud_scores')
195
- op.drop_table('lecrapaud_scores')
196
- op.drop_index(op.f('ix_lecrapaud_model_trainings_id'), table_name='lecrapaud_model_trainings')
197
- op.drop_table('lecrapaud_model_trainings')
198
- op.drop_index(op.f('ix_lecrapaud_feature_selection_ranks_id'), table_name='lecrapaud_feature_selection_ranks')
199
- op.drop_table('lecrapaud_feature_selection_ranks')
200
- op.drop_table('lecrapaud_feature_selection_association')
201
- op.drop_index(op.f('ix_lecrapaud_model_selections_id'), table_name='lecrapaud_model_selections')
202
- op.drop_table('lecrapaud_model_selections')
203
- op.drop_index(op.f('ix_lecrapaud_feature_selections_id'), table_name='lecrapaud_feature_selections')
204
- op.drop_table('lecrapaud_feature_selections')
205
- op.drop_table('lecrapaud_experiment_target_association')
206
- op.drop_index(op.f('ix_lecrapaud_targets_id'), table_name='lecrapaud_targets')
207
- op.drop_table('lecrapaud_targets')
208
- op.drop_index(op.f('ix_lecrapaud_models_id'), table_name='lecrapaud_models')
209
- op.drop_table('lecrapaud_models')
210
- op.drop_index(op.f('ix_lecrapaud_features_id'), table_name='lecrapaud_features')
211
- op.drop_table('lecrapaud_features')
212
- op.drop_index(op.f('ix_lecrapaud_experiments_id'), table_name='lecrapaud_experiments')
213
- op.drop_table('lecrapaud_experiments')
214
- # ### end Alembic commands ###
@@ -1,34 +0,0 @@
1
- """
2
-
3
- Revision ID: 86457e2f333f
4
- Revises: c62251b129ed
5
- Create Date: 2025-06-24 17:11:25.187876
6
-
7
- """
8
- from typing import Sequence, Union
9
-
10
- from alembic import op
11
- import sqlalchemy as sa
12
- from sqlalchemy.dialects import mysql
13
-
14
- # revision identifiers, used by Alembic.
15
- revision: str = '86457e2f333f'
16
- down_revision: Union[str, None] = 'c62251b129ed'
17
- branch_labels: Union[str, Sequence[str], None] = None
18
- depends_on: Union[str, Sequence[str], None] = None
19
-
20
-
21
- def upgrade() -> None:
22
- # ### commands auto generated by Alembic - please adjust! ###
23
- op.add_column('lecrapaud_scores', sa.Column('thresholds', sa.JSON(), nullable=True))
24
- op.add_column('lecrapaud_scores', sa.Column('f1_at_threshold', sa.Float(), nullable=True))
25
- op.drop_column('lecrapaud_scores', 'threshold')
26
- # ### end Alembic commands ###
27
-
28
-
29
- def downgrade() -> None:
30
- # ### commands auto generated by Alembic - please adjust! ###
31
- op.add_column('lecrapaud_scores', sa.Column('threshold', mysql.FLOAT(), nullable=True))
32
- op.drop_column('lecrapaud_scores', 'f1_at_threshold')
33
- op.drop_column('lecrapaud_scores', 'thresholds')
34
- # ### end Alembic commands ###
File without changes
File without changes
File without changes