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.
- {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/METADATA +9 -5
- dragon_ml_toolbox-16.2.1.dist-info/RECORD +51 -0
- ml_tools/ETL_cleaning.py +20 -20
- ml_tools/ETL_engineering.py +23 -25
- ml_tools/GUI_tools.py +20 -20
- ml_tools/MICE_imputation.py +3 -3
- ml_tools/ML_callbacks.py +43 -26
- ml_tools/ML_configuration.py +726 -32
- ml_tools/ML_datasetmaster.py +235 -280
- ml_tools/ML_evaluation.py +160 -42
- ml_tools/ML_evaluation_multi.py +103 -35
- ml_tools/ML_inference.py +290 -208
- ml_tools/ML_models.py +13 -102
- ml_tools/ML_models_advanced.py +1 -1
- ml_tools/ML_optimization.py +12 -12
- ml_tools/ML_scaler.py +11 -11
- ml_tools/ML_sequence_datasetmaster.py +341 -0
- ml_tools/ML_sequence_evaluation.py +219 -0
- ml_tools/ML_sequence_inference.py +391 -0
- ml_tools/ML_sequence_models.py +139 -0
- ml_tools/ML_trainer.py +1342 -386
- ml_tools/ML_utilities.py +1 -1
- ml_tools/ML_vision_datasetmaster.py +120 -72
- ml_tools/ML_vision_evaluation.py +30 -6
- ml_tools/ML_vision_inference.py +129 -152
- ml_tools/ML_vision_models.py +1 -1
- ml_tools/ML_vision_transformers.py +121 -40
- ml_tools/PSO_optimization.py +6 -6
- ml_tools/SQL.py +4 -4
- ml_tools/{keys.py → _keys.py} +45 -0
- ml_tools/_schema.py +1 -1
- ml_tools/ensemble_evaluation.py +1 -1
- ml_tools/ensemble_inference.py +7 -33
- ml_tools/ensemble_learning.py +1 -1
- ml_tools/optimization_tools.py +2 -2
- ml_tools/path_manager.py +5 -5
- ml_tools/utilities.py +1 -2
- dragon_ml_toolbox-14.7.0.dist-info/RECORD +0 -49
- ml_tools/RNN_forecast.py +0 -56
- ml_tools/_ML_vision_recipe.py +0 -88
- {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/WHEEL +0 -0
- {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/licenses/LICENSE +0 -0
- {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/licenses/LICENSE-THIRD-PARTY.md +0 -0
- {dragon_ml_toolbox-14.7.0.dist-info → dragon_ml_toolbox-16.2.1.dist-info}/top_level.txt +0 -0
ml_tools/_ML_vision_recipe.py
DELETED
|
@@ -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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|