dragon-ml-toolbox 14.7.0__py3-none-any.whl → 16.2.1__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.
Files changed (44) hide show
  1. {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/METADATA +9 -5
  2. dragon_ml_toolbox-16.2.1.dist-info/RECORD +51 -0
  3. ml_tools/ETL_cleaning.py +20 -20
  4. ml_tools/ETL_engineering.py +23 -25
  5. ml_tools/GUI_tools.py +20 -20
  6. ml_tools/MICE_imputation.py +3 -3
  7. ml_tools/ML_callbacks.py +43 -26
  8. ml_tools/ML_configuration.py +726 -32
  9. ml_tools/ML_datasetmaster.py +235 -280
  10. ml_tools/ML_evaluation.py +160 -42
  11. ml_tools/ML_evaluation_multi.py +103 -35
  12. ml_tools/ML_inference.py +290 -208
  13. ml_tools/ML_models.py +13 -102
  14. ml_tools/ML_models_advanced.py +1 -1
  15. ml_tools/ML_optimization.py +12 -12
  16. ml_tools/ML_scaler.py +11 -11
  17. ml_tools/ML_sequence_datasetmaster.py +341 -0
  18. ml_tools/ML_sequence_evaluation.py +219 -0
  19. ml_tools/ML_sequence_inference.py +391 -0
  20. ml_tools/ML_sequence_models.py +139 -0
  21. ml_tools/ML_trainer.py +1342 -386
  22. ml_tools/ML_utilities.py +1 -1
  23. ml_tools/ML_vision_datasetmaster.py +120 -72
  24. ml_tools/ML_vision_evaluation.py +30 -6
  25. ml_tools/ML_vision_inference.py +129 -152
  26. ml_tools/ML_vision_models.py +1 -1
  27. ml_tools/ML_vision_transformers.py +121 -40
  28. ml_tools/PSO_optimization.py +6 -6
  29. ml_tools/SQL.py +4 -4
  30. ml_tools/{keys.py → _keys.py} +45 -0
  31. ml_tools/_schema.py +1 -1
  32. ml_tools/ensemble_evaluation.py +1 -1
  33. ml_tools/ensemble_inference.py +7 -33
  34. ml_tools/ensemble_learning.py +1 -1
  35. ml_tools/optimization_tools.py +2 -2
  36. ml_tools/path_manager.py +5 -5
  37. ml_tools/utilities.py +1 -2
  38. dragon_ml_toolbox-14.7.0.dist-info/RECORD +0 -49
  39. ml_tools/RNN_forecast.py +0 -56
  40. ml_tools/_ML_vision_recipe.py +0 -88
  41. {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/WHEEL +0 -0
  42. {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/licenses/LICENSE +0 -0
  43. {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/licenses/LICENSE-THIRD-PARTY.md +0 -0
  44. {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/top_level.txt +0 -0
@@ -1,88 +0,0 @@
1
- import json
2
- import torch
3
- from torchvision import transforms
4
- from typing import Dict, Any, List, Callable, Union
5
- from pathlib import Path
6
-
7
- from .ML_vision_transformers import TRANSFORM_REGISTRY
8
- from ._logger import _LOGGER
9
- from .keys import VisionTransformRecipeKeys
10
- from .path_manager import make_fullpath
11
-
12
-
13
- def save_recipe(recipe: Dict[str, Any], filepath: Path) -> None:
14
- """
15
- Saves a transform recipe dictionary to a JSON file.
16
-
17
- Args:
18
- recipe (Dict[str, Any]): The recipe dictionary to save.
19
- filepath (str): The path to the output .json file.
20
- """
21
- final_filepath = filepath.with_suffix(".json")
22
-
23
- try:
24
- with open(final_filepath, 'w') as f:
25
- json.dump(recipe, f, indent=4)
26
- _LOGGER.info(f"Transform recipe saved as '{final_filepath.name}'.")
27
- except Exception as e:
28
- _LOGGER.error(f"Failed to save recipe to '{final_filepath}': {e}")
29
- raise
30
-
31
-
32
- def load_recipe_and_build_transform(filepath: Union[str,Path]) -> transforms.Compose:
33
- """
34
- Loads a transform recipe from a .json file and reconstructs the
35
- torchvision.transforms.Compose pipeline.
36
-
37
- Args:
38
- filepath (str): Path to the saved transform recipe .json file.
39
-
40
- Returns:
41
- transforms.Compose: The reconstructed transformation pipeline.
42
-
43
- Raises:
44
- ValueError: If a transform name in the recipe is not found in
45
- torchvision.transforms or the custom TRANSFORM_REGISTRY.
46
- """
47
- # validate filepath
48
- final_filepath = make_fullpath(filepath, enforce="file")
49
-
50
- try:
51
- with open(final_filepath, 'r') as f:
52
- recipe = json.load(f)
53
- except Exception as e:
54
- _LOGGER.error(f"Failed to load recipe from '{final_filepath}': {e}")
55
- raise
56
-
57
- pipeline_steps: List[Callable] = []
58
-
59
- if VisionTransformRecipeKeys.PIPELINE not in recipe:
60
- _LOGGER.error("Recipe file is invalid: missing 'pipeline' key.")
61
- raise ValueError("Invalid recipe format.")
62
-
63
- for step in recipe[VisionTransformRecipeKeys.PIPELINE]:
64
- t_name = step[VisionTransformRecipeKeys.NAME]
65
- t_kwargs = step[VisionTransformRecipeKeys.KWARGS]
66
-
67
- transform_class: Any = None
68
-
69
- # 1. Check standard torchvision transforms
70
- if hasattr(transforms, t_name):
71
- transform_class = getattr(transforms, t_name)
72
- # 2. Check custom transforms
73
- elif t_name in TRANSFORM_REGISTRY:
74
- transform_class = TRANSFORM_REGISTRY[t_name]
75
- # 3. Not found
76
- else:
77
- _LOGGER.error(f"Unknown transform '{t_name}' in recipe. Not found in torchvision.transforms or TRANSFORM_REGISTRY.")
78
- raise ValueError(f"Unknown transform name: {t_name}")
79
-
80
- # Instantiate the transform
81
- try:
82
- pipeline_steps.append(transform_class(**t_kwargs))
83
- except Exception as e:
84
- _LOGGER.error(f"Failed to instantiate transform '{t_name}' with kwargs {t_kwargs}: {e}")
85
- raise
86
-
87
- _LOGGER.info(f"Successfully loaded and built transform pipeline from '{final_filepath.name}'.")
88
- return transforms.Compose(pipeline_steps)