dragon-ml-toolbox 14.3.1__py3-none-any.whl → 16.0.0__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 dragon-ml-toolbox might be problematic. Click here for more details.

Files changed (44) hide show
  1. {dragon_ml_toolbox-14.3.1.dist-info → dragon_ml_toolbox-16.0.0.dist-info}/METADATA +10 -5
  2. dragon_ml_toolbox-16.0.0.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 +309 -0
  9. ml_tools/ML_datasetmaster.py +220 -260
  10. ml_tools/ML_evaluation.py +317 -81
  11. ml_tools/ML_evaluation_multi.py +127 -36
  12. ml_tools/ML_inference.py +249 -207
  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 +215 -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 +1247 -338
  22. ml_tools/ML_utilities.py +51 -2
  23. ml_tools/ML_vision_datasetmaster.py +262 -118
  24. ml_tools/ML_vision_evaluation.py +26 -6
  25. ml_tools/ML_vision_inference.py +117 -140
  26. ml_tools/ML_vision_models.py +15 -1
  27. ml_tools/ML_vision_transformers.py +233 -7
  28. ml_tools/PSO_optimization.py +6 -6
  29. ml_tools/SQL.py +4 -4
  30. ml_tools/{keys.py → _keys.py} +45 -1
  31. ml_tools/_schema.py +1 -1
  32. ml_tools/ensemble_evaluation.py +54 -11
  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.3.1.dist-info/RECORD +0 -48
  39. ml_tools/RNN_forecast.py +0 -56
  40. ml_tools/_ML_vision_recipe.py +0 -88
  41. {dragon_ml_toolbox-14.3.1.dist-info → dragon_ml_toolbox-16.0.0.dist-info}/WHEEL +0 -0
  42. {dragon_ml_toolbox-14.3.1.dist-info → dragon_ml_toolbox-16.0.0.dist-info}/licenses/LICENSE +0 -0
  43. {dragon_ml_toolbox-14.3.1.dist-info → dragon_ml_toolbox-16.0.0.dist-info}/licenses/LICENSE-THIRD-PARTY.md +0 -0
  44. {dragon_ml_toolbox-14.3.1.dist-info → dragon_ml_toolbox-16.0.0.dist-info}/top_level.txt +0 -0
ml_tools/path_manager.py CHANGED
@@ -9,7 +9,7 @@ from ._logger import _LOGGER
9
9
 
10
10
 
11
11
  __all__ = [
12
- "PathManager",
12
+ "DragonPathManager",
13
13
  "make_fullpath",
14
14
  "sanitize_filename",
15
15
  "list_csv_paths",
@@ -18,7 +18,7 @@ __all__ = [
18
18
  ]
19
19
 
20
20
 
21
- class PathManager:
21
+ class DragonPathManager:
22
22
  """
23
23
  Manages and stores a project's file paths, acting as a centralized
24
24
  "path database". It supports both development mode and applications
@@ -43,7 +43,7 @@ class PathManager:
43
43
 
44
44
  Args:
45
45
  anchor_file (str): The path to a file within your package, typically
46
- the `__file__` of the script where PathManager
46
+ the `__file__` of the script where DragonPathManager
47
47
  is instantiated. This is used to locate the
48
48
  package root directory.
49
49
  base_directories (List[str] | None): An optional list of strings,
@@ -149,7 +149,7 @@ class PathManager:
149
149
  if key in self._paths:
150
150
  path_items.append((key, self._paths[key]))
151
151
  elif verbose:
152
- _LOGGER.warning(f"Key '{key}' not found in PathManager, skipping.")
152
+ _LOGGER.warning(f"Key '{key}' not found in DragonPathManager, skipping.")
153
153
  else:
154
154
  path_items = self._paths.items()
155
155
 
@@ -194,7 +194,7 @@ class PathManager:
194
194
  def __repr__(self) -> str:
195
195
  """Provides a string representation of the stored paths."""
196
196
  path_list = "\n".join(f" '{k}': '{v}'" for k, v in self._paths.items())
197
- return f"PathManager(\n{path_list}\n)"
197
+ return f"DragonPathManager(\n{path_list}\n)"
198
198
 
199
199
  # --- Dictionary-Style Methods ---
200
200
  def __getitem__(self, key: str) -> Path:
ml_tools/utilities.py CHANGED
@@ -10,7 +10,6 @@ from ._logger import _LOGGER
10
10
  from ._schema import FeatureSchema
11
11
 
12
12
 
13
- # Keep track of available tools
14
13
  __all__ = [
15
14
  "load_dataframe",
16
15
  "load_dataframe_greedy",
@@ -361,7 +360,7 @@ def save_dataframe_filename(df: Union[pd.DataFrame, pl.DataFrame], save_dir: Uni
361
360
  elif isinstance(df, pl.DataFrame):
362
361
  # Transform empty strings to Null
363
362
  df_to_save = df.with_columns(
364
- pl.when(pl.col(pl.Utf8).str.strip() == "")
363
+ pl.when(pl.col(pl.Utf8).str.strip() == "") # type: ignore
365
364
  .then(None)
366
365
  .otherwise(pl.col(pl.Utf8))
367
366
  )
@@ -1,48 +0,0 @@
1
- dragon_ml_toolbox-14.3.1.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
2
- dragon_ml_toolbox-14.3.1.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=gkOdNDbKYpIJezwSo2CEnISkLeYfYHv9t8b5K2-P69A,2687
3
- ml_tools/ETL_cleaning.py,sha256=2VBRllV8F-ZiPylPp8Az2gwn5ztgazN0BH5OKnRUhV0,20402
4
- ml_tools/ETL_engineering.py,sha256=KfYqgsxupAx6e_TxwO1LZXeu5mFkIhVXJrNjP3CzIZc,54927
5
- ml_tools/GUI_tools.py,sha256=Va6ig-dHULPVRwQYYtH3fvY5XPIoqRcJpRW8oXC55Hw,45413
6
- ml_tools/MICE_imputation.py,sha256=KLJXGQLKJ6AuWWttAG-LCCaxpS-ygM4dXPiguHDaL6Y,20815
7
- ml_tools/ML_callbacks.py,sha256=elD2Yr030sv_6gX_m9GVd6HTyrbmt34nFS8lrgS4HtM,15808
8
- ml_tools/ML_datasetmaster.py,sha256=rsJgZEGBJmfeKF6cR8CQZzfEx4T7Y-p1wUnR15_nNw0,28400
9
- ml_tools/ML_evaluation.py,sha256=4GU86rUWMIGbkXrvN6PyjfGwKtWvXKE7pMlWpWeBq14,18988
10
- ml_tools/ML_evaluation_multi.py,sha256=rJKdgtq-9I7oaI7PRzq7aIZ84XdNV0xzlVePZW4nj0k,16095
11
- ml_tools/ML_inference.py,sha256=YJ953bhNWsdlPRtJQh3h2ACfMIgp8dQ9KtL9Azar-5s,23489
12
- ml_tools/ML_models.py,sha256=PqOcNlws7vCJMbiVCKqlPuktxvskZVUHG3VfU-Yshf8,31415
13
- ml_tools/ML_models_advanced.py,sha256=vk3PZBSu3DVso2S1rKTxxdS43XG8Q5FnasIL3-rMajc,12410
14
- ml_tools/ML_optimization.py,sha256=P0zkhKAwTpkorIBtR0AOIDcyexo5ngmvFUzo3DfNO-E,22692
15
- ml_tools/ML_scaler.py,sha256=tw6onj9o8_kk3FQYb930HUzvv1zsFZe2YZJdF3LtHkU,7538
16
- ml_tools/ML_trainer.py,sha256=ZWI4MbUcLeBxyfoUTL96l5tjHHMp9I64h4SdXnjYmBE,49795
17
- ml_tools/ML_utilities.py,sha256=z6LbpbZwhn8F__fWlKi-g-cAJQXSxwg1NHfC5FBoAyc,21139
18
- ml_tools/ML_vision_datasetmaster.py,sha256=2S7stCgGQX39Y38gfMQccwAx_QTKEmmRIqh4XJ2K_YE,58041
19
- ml_tools/ML_vision_evaluation.py,sha256=t12R7i1RkOCt9zu1_lxSBr8OH6A6Get0k8ftDLctn6I,10486
20
- ml_tools/ML_vision_inference.py,sha256=He3KV3VJAm8PwO-fOq4b9VO8UXFr-GmpuCnoHXf4VZI,20588
21
- ml_tools/ML_vision_models.py,sha256=G3S4jB9AE9wMpU9ZygOgOx9q1K6t6LAXBYcJ-U2XQ1M,25600
22
- ml_tools/ML_vision_transformers.py,sha256=95e0aBkHY5VDGE8i5xy57COU7NvSNIgFknnhBubwE40,1832
23
- ml_tools/PSO_optimization.py,sha256=T-HWHMRJUnPvPwixdU5jif3_rnnI36TzcL8u3oSCwuA,22960
24
- ml_tools/RNN_forecast.py,sha256=Qa2KoZfdAvSjZ4yE78N4BFXtr3tTr0Gx7tQJZPotsh0,1967
25
- ml_tools/SQL.py,sha256=vXLPGfVVg8bfkbBE3HVfyEclVbdJy0TBhuQONtMwSCQ,11234
26
- ml_tools/VIF_factor.py,sha256=at5IVqPvicja2-DNSTSIIy3SkzDWCmLzo3qTG_qr5n8,10422
27
- ml_tools/_ML_vision_recipe.py,sha256=zrgxFUvTJqQVuwR7jWlbIC2FD29u6eNFPkTRoJ7yEZI,3178
28
- ml_tools/__init__.py,sha256=kJiankjz9_qXu7gU92mYqYg_anLvt-B6RtW0mMH8uGo,76
29
- ml_tools/_logger.py,sha256=dlp5cGbzooK9YSNSZYB4yjZrOaQUGW8PTrM411AOvL8,4717
30
- ml_tools/_schema.py,sha256=yu6aWmn_2Z4_AxAtJGDDCIa96y6JcUp-vgnCS013Qmw,3908
31
- ml_tools/_script_info.py,sha256=21r83LV3RubsNZ_RTEUON6RbDf7Mh4_udweNcvdF_Fk,212
32
- ml_tools/constants.py,sha256=3br5Rk9cL2IUo638eJuMOGdbGQaWssaUecYEvSeRBLM,3322
33
- ml_tools/custom_logger.py,sha256=TGc0Ww2Xlqj2XE3q4bP43hV7T3qnb5ci9f0pYHXF5TY,11226
34
- ml_tools/data_exploration.py,sha256=bwHzFJ-IAo5GN3T53F-1J_pXUg8VHS91sG_90utAsfg,69911
35
- ml_tools/ensemble_evaluation.py,sha256=FGHSe8LBI8_w8LjNeJWOcYQ1UK_mc6fVah8gmSvNVGg,26853
36
- ml_tools/ensemble_inference.py,sha256=0yLmLNj45RVVoSCLH1ZYJG9IoAhTkWUqEZmLOQTFGTY,9348
37
- ml_tools/ensemble_learning.py,sha256=vsIED7nlheYI4w2SBzP6SC1AnNeMfn-2A1Gqw5EfxsM,21964
38
- ml_tools/handle_excel.py,sha256=pfdAPb9ywegFkM9T54bRssDOsX-K7rSeV0RaMz7lEAo,14006
39
- ml_tools/keys.py,sha256=wZOBuEnnHc54vlOZiimnrxfk-sZh6f6suPppJW8rbPQ,3326
40
- ml_tools/math_utilities.py,sha256=xeKq1quR_3DYLgowcp4Uam_4s3JltUyOnqMOGuAiYWU,8802
41
- ml_tools/optimization_tools.py,sha256=TYFQ2nSnp7xxs-VyoZISWgnGJghFbsWasHjruegyJRs,12763
42
- ml_tools/path_manager.py,sha256=CyDU16pOKmC82jPubqJPT6EBt-u-3rGVbxyPIZCvDDY,18432
43
- ml_tools/serde.py,sha256=c8uDYjYry_VrLvoG4ixqDj5pij88lVn6Tu4NHcPkwDU,6943
44
- ml_tools/utilities.py,sha256=aWqvYzmxlD74PD5Yqu1VuTekDJeYLQrmPIU_VeVyRp0,22526
45
- dragon_ml_toolbox-14.3.1.dist-info/METADATA,sha256=dNN-vygEF2WikswJ-6XCShUDf3rD2-XRNtz0vvRg2-4,6475
46
- dragon_ml_toolbox-14.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
- dragon_ml_toolbox-14.3.1.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
48
- dragon_ml_toolbox-14.3.1.dist-info/RECORD,,
ml_tools/RNN_forecast.py DELETED
@@ -1,56 +0,0 @@
1
- import torch
2
- from torch import nn
3
- import numpy as np
4
-
5
- from ._script_info import _script_info
6
-
7
-
8
- __all__ = [
9
- "rnn_forecast"
10
- ]
11
-
12
- def rnn_forecast(model: nn.Module, start_sequence: torch.Tensor, steps: int, device: str = 'cpu'):
13
- """
14
- Runs a sequential forecast for a trained RNN-based model.
15
-
16
- This function iteratively predicts future time steps, where each new prediction
17
- is generated by feeding the previous prediction back into the model.
18
-
19
- Args:
20
- model (nn.Module): The trained PyTorch RNN model (e.g., LSTM, GRU).
21
- start_sequence (torch.Tensor): The initial sequence to start the forecast from.
22
- Shape should be (sequence_length, num_features).
23
- steps (int): The number of future time steps to predict.
24
- device (str, optional): The device to run the forecast on ('cpu', 'cuda', 'mps').
25
- Defaults to 'cpu'.
26
-
27
- Returns:
28
- np.ndarray: A numpy array containing the forecasted values.
29
- """
30
- model.eval()
31
- model.to(device)
32
-
33
- predictions = []
34
- current_sequence = start_sequence.to(device)
35
-
36
- with torch.no_grad():
37
- for _ in range(steps):
38
- # Get the model's prediction for the current sequence
39
- output = model(current_sequence.unsqueeze(0)) # Add batch dimension
40
-
41
- # The prediction is the last element of the output sequence
42
- next_pred = output[0, -1, :].view(1, -1)
43
-
44
- # Store the prediction
45
- predictions.append(next_pred.cpu().numpy())
46
-
47
- # Update the sequence for the next iteration:
48
- # Drop the first element and append the new prediction
49
- current_sequence = torch.cat([current_sequence[1:], next_pred], dim=0)
50
-
51
- # Concatenate all predictions and flatten the array for easy use
52
- return np.concatenate(predictions).flatten()
53
-
54
-
55
- def info():
56
- _script_info(__all__)
@@ -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)