lecrapaud 0.11.6__tar.gz → 0.12.1__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 (44) hide show
  1. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/PKG-INFO +1 -1
  2. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/api.py +4 -3
  3. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/model_selection.py +26 -21
  4. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/pyproject.toml +1 -1
  5. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/LICENSE +0 -0
  6. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/README.md +0 -0
  7. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/__init__.py +0 -0
  8. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/config.py +0 -0
  9. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/__init__.py +0 -0
  10. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/README +0 -0
  11. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/env.py +0 -0
  12. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/script.py.mako +0 -0
  13. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py +0 -0
  14. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/versions/2025_06_24_1216-c62251b129ed_.py +0 -0
  15. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py +0 -0
  16. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic/versions/2025_06_25_1759-72aa496ca65b_.py +0 -0
  17. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/alembic.ini +0 -0
  18. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/__init__.py +0 -0
  19. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/base.py +0 -0
  20. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/experiment.py +0 -0
  21. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/feature.py +0 -0
  22. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/feature_selection.py +0 -0
  23. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/feature_selection_rank.py +0 -0
  24. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/model.py +0 -0
  25. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/model_selection.py +0 -0
  26. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/model_training.py +0 -0
  27. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/score.py +0 -0
  28. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/models/target.py +0 -0
  29. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/db/session.py +0 -0
  30. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/directories.py +0 -0
  31. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/experiment.py +0 -0
  32. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/feature_engineering.py +0 -0
  33. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/feature_selection.py +0 -0
  34. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/integrations/openai_integration.py +0 -0
  35. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/jobs/__init__.py +0 -0
  36. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/jobs/config.py +0 -0
  37. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/jobs/scheduler.py +0 -0
  38. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/jobs/tasks.py +0 -0
  39. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/misc/tabpfn_tests.ipynb +0 -0
  40. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/misc/test-gpu-bilstm.ipynb +0 -0
  41. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/misc/test-gpu-resnet.ipynb +0 -0
  42. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/misc/test-gpu-transformers.ipynb +0 -0
  43. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/search_space.py +0 -0
  44. {lecrapaud-0.11.6 → lecrapaud-0.12.1}/lecrapaud/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lecrapaud
3
- Version: 0.11.6
3
+ Version: 0.12.1
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
@@ -128,7 +128,7 @@ class ExperimentEngine:
128
128
  value = normalize_models_idx(value)
129
129
  setattr(self, key, value)
130
130
 
131
- def train(self, data):
131
+ def train(self, data, best_params=None):
132
132
  logger.info("Running training...")
133
133
 
134
134
  data_eng = self.feature_engineering(data)
@@ -143,7 +143,7 @@ class ExperimentEngine:
143
143
  std_data, reshaped_data = self.preprocess_model(train, val, test)
144
144
  logger.info("Model preprocessing done.")
145
145
 
146
- self.model_selection(std_data, reshaped_data)
146
+ self.model_selection(std_data, reshaped_data, best_params=best_params)
147
147
  logger.info("Model selection done.")
148
148
 
149
149
  def predict(self, new_data, verbose: int = 0):
@@ -321,7 +321,7 @@ class ExperimentEngine:
321
321
  data, scaled_data, reshaped_data = app.inference()
322
322
  return data, scaled_data, reshaped_data
323
323
 
324
- def model_selection(self, data, reshaped_data):
324
+ def model_selection(self, data, reshaped_data, best_params=None):
325
325
  for target_number in self.target_numbers:
326
326
  app = ModelSelectionEngine(
327
327
  data=data,
@@ -342,6 +342,7 @@ class ExperimentEngine:
342
342
  perform_crossval=self.perform_crossval,
343
343
  plot=self.plot,
344
344
  preserve_model=self.preserve_model,
345
+ best_params=best_params[target_number],
345
346
  )
346
347
 
347
348
  def get_scores(self, target_number: int):
@@ -721,6 +721,7 @@ class ModelSelectionEngine:
721
721
  plot=True,
722
722
  clean_dir=False, # TODO: This has been unused because now feature_selection is in the target directory
723
723
  preserve_model=True,
724
+ best_params=None,
724
725
  ):
725
726
  """
726
727
  Selects the best models based on a target variable, optionally performing hyperparameter optimization
@@ -866,29 +867,33 @@ class ModelSelectionEngine:
866
867
  start = time.time()
867
868
  # Tuning hyperparameters
868
869
  if perform_hyperopt:
869
- best_params = self.hyperoptimize(x_train, y_train, x_val, y_val, model)
870
-
871
- # save best params
872
- best_params_file = f"{self.target_dir}/best_params.json"
873
- try:
874
- with open(best_params_file, "r") as f:
875
- json_dict = json.load(f)
876
- except FileNotFoundError:
877
- json_dict = {}
878
-
879
- json_dict[model.model_name] = serialize_for_json(best_params)
880
- with open(best_params_file, "w") as f:
881
- json.dump(json_dict, f, indent=4)
870
+ model_best_params = self.hyperoptimize(
871
+ x_train, y_train, x_val, y_val, model
872
+ )
873
+ elif best_params:
874
+ model_best_params = best_params[model_name]
882
875
  else:
883
876
  try:
884
877
  with open(f"{self.target_dir}/best_params.json") as f:
885
878
  json_dict = json.load(f)
886
- best_params = json_dict[model_name]
879
+ model_best_params = json_dict[model_name]
887
880
  except Exception:
888
881
  raise FileNotFoundError(
889
- f"Could not find {model_name} in current data. Try to run an hyperoptimization by setting `perform_hyperopt` to true"
882
+ f"Could not find {model_name} in current data. Try to run an hyperoptimization by setting `perform_hyperopt` to true, pass `best_params`"
890
883
  )
891
884
 
885
+ # save best params
886
+ best_params_file = f"{self.target_dir}/best_params.json"
887
+ try:
888
+ with open(best_params_file, "r") as f:
889
+ json_dict = json.load(f)
890
+ except FileNotFoundError:
891
+ json_dict = {}
892
+
893
+ json_dict[model.model_name] = serialize_for_json(model_best_params)
894
+ with open(best_params_file, "w") as f:
895
+ json.dump(json_dict, f, indent=4)
896
+
892
897
  # Perform cross-validation of the best model on k-folds of train + val set
893
898
  if perform_crossval:
894
899
  x_train_val = pd.concat([x_train, x_val, x_test], axis=0)
@@ -928,7 +933,7 @@ class ModelSelectionEngine:
928
933
  # Train the model and get the score
929
934
  if recurrent:
930
935
  cross_validation_score, _, _ = self.train_model(
931
- params=best_params,
936
+ params=model_best_params,
932
937
  x_train=x_train_val[train_index],
933
938
  y_train=y_train_val[train_index],
934
939
  x_val=x_train_val[val_index],
@@ -937,7 +942,7 @@ class ModelSelectionEngine:
937
942
  )
938
943
  else:
939
944
  cross_validation_score, _, _ = self.train_model(
940
- params=best_params,
945
+ params=model_best_params,
941
946
  x_train=x_train_val.iloc[train_index],
942
947
  y_train=y_train_val.iloc[train_index],
943
948
  x_val=x_train_val.iloc[val_index],
@@ -958,7 +963,7 @@ class ModelSelectionEngine:
958
963
 
959
964
  # Retrain on entire training set, but keep score on cross-validation folds
960
965
  best_score, best_model, best_pred = self.train_model(
961
- params=best_params,
966
+ params=model_best_params,
962
967
  x_train=pd.concat([x_train, x_val], axis=0),
963
968
  y_train=pd.concat([y_train, y_val], axis=0),
964
969
  x_val=x_test,
@@ -970,7 +975,7 @@ class ModelSelectionEngine:
970
975
  # Evaluate on validation set
971
976
  self.type_name = "validation"
972
977
  best_score, best_model, best_pred = self.train_model(
973
- params=best_params,
978
+ params=model_best_params,
974
979
  x_train=pd.concat([x_train, x_val], axis=0),
975
980
  y_train=pd.concat([y_train, y_val], axis=0),
976
981
  x_val=x_test,
@@ -1016,7 +1021,7 @@ class ModelSelectionEngine:
1016
1021
  # Save model training metadata
1017
1022
  stop = time.time()
1018
1023
  training_time = stop - start
1019
- model_training.best_params = best_params
1024
+ model_training.best_params = model_best_params
1020
1025
  model_training.model_path = model_path
1021
1026
  model_training.training_time = training_time
1022
1027
  model_training.save()
@@ -1138,7 +1143,7 @@ class ModelSelectionEngine:
1138
1143
  try:
1139
1144
  results = tuner.fit()
1140
1145
 
1141
- best_result = results.get_best_result(self.metric, "max")
1146
+ best_result = results.get_best_result(self.metric, "min")
1142
1147
  best_params = best_result.config
1143
1148
  best_score = best_result.metrics
1144
1149
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lecrapaud"
3
- version = "0.11.6"
3
+ version = "0.12.1"
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"}
File without changes
File without changes