dragon-ml-toolbox 13.2.0__py3-none-any.whl → 13.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dragon-ml-toolbox
3
- Version: 13.2.0
3
+ Version: 13.3.0
4
4
  Summary: A collection of tools for data science and machine learning projects.
5
5
  Author-email: "Karl L. Loza Vidaurre" <luigiloza@gmail.com>
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
- dragon_ml_toolbox-13.2.0.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
2
- dragon_ml_toolbox-13.2.0.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=iy2r_R7wjzsCbz_Q_jMsp_jfZ6oP8XW9QhwzRBH0mGY,1904
1
+ dragon_ml_toolbox-13.3.0.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
2
+ dragon_ml_toolbox-13.3.0.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=iy2r_R7wjzsCbz_Q_jMsp_jfZ6oP8XW9QhwzRBH0mGY,1904
3
3
  ml_tools/ETL_cleaning.py,sha256=2VBRllV8F-ZiPylPp8Az2gwn5ztgazN0BH5OKnRUhV0,20402
4
4
  ml_tools/ETL_engineering.py,sha256=KfYqgsxupAx6e_TxwO1LZXeu5mFkIhVXJrNjP3CzIZc,54927
5
5
  ml_tools/GUI_tools.py,sha256=Va6ig-dHULPVRwQYYtH3fvY5XPIoqRcJpRW8oXC55Hw,45413
@@ -20,11 +20,11 @@ ml_tools/SQL.py,sha256=vXLPGfVVg8bfkbBE3HVfyEclVbdJy0TBhuQONtMwSCQ,11234
20
20
  ml_tools/VIF_factor.py,sha256=at5IVqPvicja2-DNSTSIIy3SkzDWCmLzo3qTG_qr5n8,10422
21
21
  ml_tools/__init__.py,sha256=kJiankjz9_qXu7gU92mYqYg_anLvt-B6RtW0mMH8uGo,76
22
22
  ml_tools/_logger.py,sha256=dlp5cGbzooK9YSNSZYB4yjZrOaQUGW8PTrM411AOvL8,4717
23
- ml_tools/_schema.py,sha256=MloQLJvuYzWHbmHfp0rUx5vgTPdfusfQ1b83KY277bY,2767
23
+ ml_tools/_schema.py,sha256=yu6aWmn_2Z4_AxAtJGDDCIa96y6JcUp-vgnCS013Qmw,3908
24
24
  ml_tools/_script_info.py,sha256=21r83LV3RubsNZ_RTEUON6RbDf7Mh4_udweNcvdF_Fk,212
25
25
  ml_tools/constants.py,sha256=3br5Rk9cL2IUo638eJuMOGdbGQaWssaUecYEvSeRBLM,3322
26
26
  ml_tools/custom_logger.py,sha256=7tSAgRL7e-Ekm7rS1FLDocaPLCnaoKc7VSrtfwCtCEg,10067
27
- ml_tools/data_exploration.py,sha256=aVcxjoXVqrmFBpwBSbLvrG8quzJfr92On48Sy3K58Vs,51900
27
+ ml_tools/data_exploration.py,sha256=-BbWO7BBFapPi_7ZuWo65VqguJXaBfgFSptrXyoWrDk,51902
28
28
  ml_tools/ensemble_evaluation.py,sha256=FGHSe8LBI8_w8LjNeJWOcYQ1UK_mc6fVah8gmSvNVGg,26853
29
29
  ml_tools/ensemble_inference.py,sha256=0yLmLNj45RVVoSCLH1ZYJG9IoAhTkWUqEZmLOQTFGTY,9348
30
30
  ml_tools/ensemble_learning.py,sha256=vsIED7nlheYI4w2SBzP6SC1AnNeMfn-2A1Gqw5EfxsM,21964
@@ -33,9 +33,9 @@ ml_tools/keys.py,sha256=oykUVLB4Wos3AZomowjtI8AFFC5xnMUH-icNHydRpOk,2275
33
33
  ml_tools/math_utilities.py,sha256=PxoOrnuj6Ntp7_TJqyDWi0JX03WpAO5iaFNK2Oeq5I4,8800
34
34
  ml_tools/optimization_tools.py,sha256=TYFQ2nSnp7xxs-VyoZISWgnGJghFbsWasHjruegyJRs,12763
35
35
  ml_tools/path_manager.py,sha256=CyDU16pOKmC82jPubqJPT6EBt-u-3rGVbxyPIZCvDDY,18432
36
- ml_tools/serde.py,sha256=IHXHS2XwpEe5Y8mdWvR2SAykOriB8CysDuD70SvtikQ,6223
36
+ ml_tools/serde.py,sha256=CmdJmQCPdrm2RQA1hWLsGxU_B3aClQoQ9B4vcQtIrEs,6951
37
37
  ml_tools/utilities.py,sha256=OcAyV1tEcYAfOWlGjRgopsjDLxU3DcI5EynzvWV4q3A,15754
38
- dragon_ml_toolbox-13.2.0.dist-info/METADATA,sha256=NzCUzaOdHUWqWZ7B96xs-rywNbalnz5MAlduLaowvX8,6166
39
- dragon_ml_toolbox-13.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- dragon_ml_toolbox-13.2.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
41
- dragon_ml_toolbox-13.2.0.dist-info/RECORD,,
38
+ dragon_ml_toolbox-13.3.0.dist-info/METADATA,sha256=m2RVQa8YeN6e4hnsg6TwAMjymhTrburFXbmw-yB8JeQ,6166
39
+ dragon_ml_toolbox-13.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ dragon_ml_toolbox-13.3.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
41
+ dragon_ml_toolbox-13.3.0.dist-info/RECORD,,
ml_tools/_schema.py CHANGED
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
 
4
4
  from .custom_logger import save_list_strings
5
5
  from .keys import DatasetKeys
6
+ from ._logger import _LOGGER
6
7
 
7
8
 
8
9
  class FeatureSchema(NamedTuple):
@@ -25,6 +26,12 @@ class FeatureSchema(NamedTuple):
25
26
 
26
27
  def _save_helper(self, artifact: Tuple[str, ...], directory: Union[str,Path], filename: str, verbose: bool):
27
28
  to_save = list(artifact)
29
+
30
+ # empty check
31
+ if not to_save:
32
+ _LOGGER.warning(f"Skipping save for '{filename}': The feature list is empty.")
33
+ return
34
+
28
35
  save_list_strings(list_strings=to_save,
29
36
  directory=directory,
30
37
  filename=filename,
@@ -68,3 +75,22 @@ class FeatureSchema(NamedTuple):
68
75
  directory=directory,
69
76
  filename=DatasetKeys.CATEGORICAL_NAMES,
70
77
  verbose=verbose)
78
+
79
+ def save_artifacts(self, directory: Union[str,Path]):
80
+ """
81
+ Saves feature names, categorical feature names, continuous feature names to separate text files.
82
+ """
83
+ self.save_all_features(directory=directory, verbose=True)
84
+ self.save_continuous_features(directory=directory, verbose=True)
85
+ self.save_categorical_features(directory=directory, verbose=True)
86
+
87
+ def __repr__(self) -> str:
88
+ """Returns a concise representation of the schema's contents."""
89
+ total = len(self.feature_names)
90
+ cont = len(self.continuous_feature_names)
91
+ cat = len(self.categorical_feature_names)
92
+ index_map = self.categorical_index_map is not None
93
+ cat_map = self.categorical_mappings is not None
94
+ return (
95
+ f"<FeatureSchema(total={total}, continuous={cont}, categorical={cat}, index_map={index_map}, categorical_map={cat_map})>"
96
+ )
@@ -1262,7 +1262,7 @@ def finalize_feature_schema(
1262
1262
  categorical_feature_names_list: List[str] = []
1263
1263
  categorical_index_map_dict: Dict[int, int] = {}
1264
1264
 
1265
- _LOGGER.info("Finalizing feature schema...")
1265
+ # _LOGGER.info("Finalizing feature schema...")
1266
1266
 
1267
1267
  if categorical_mappings:
1268
1268
  # --- Categorical features are present ---
ml_tools/serde.py CHANGED
@@ -18,6 +18,10 @@ __all__ = [
18
18
  ]
19
19
 
20
20
 
21
+ # Base types that have a generic `type()` log.
22
+ _SIMPLE_TYPES = (list, dict, tuple, set, str, int, float, bool)
23
+
24
+
21
25
  def serialize_object_filename(obj: Any, save_dir: Union[str,Path], filename: str, verbose: bool=True, raise_on_error: bool=False) -> None:
22
26
  """
23
27
  Serializes a Python object using joblib; suitable for Python built-ins, numpy, and pandas.
@@ -27,6 +31,10 @@ def serialize_object_filename(obj: Any, save_dir: Union[str,Path], filename: str
27
31
  save_dir (str | Path) : Directory path where the serialized object will be saved.
28
32
  filename (str) : Name for the output file, extension will be appended if needed.
29
33
  """
34
+ if obj is None:
35
+ _LOGGER.warning(f"Attempted to serialize a None object. Skipping save for '{filename}'.")
36
+ return
37
+
30
38
  try:
31
39
  save_path = make_fullpath(save_dir, make=True, enforce="directory")
32
40
  sanitized_name = sanitize_filename(filename)
@@ -56,6 +64,10 @@ def serialize_object(obj: Any, file_path: Path, verbose: bool = True, raise_on_e
56
64
  '.joblib' extension will be appended if missing.
57
65
  raise_on_error (bool) : If True, raises exceptions on failure.
58
66
  """
67
+ if obj is None:
68
+ _LOGGER.warning(f"Attempted to serialize a None object. Skipping save for '{file_path}'.")
69
+ return
70
+
59
71
  try:
60
72
  # Ensure the extension is correct
61
73
  file_path = file_path.with_suffix('.joblib')
@@ -73,7 +85,11 @@ def serialize_object(obj: Any, file_path: Path, verbose: bool = True, raise_on_e
73
85
  return None
74
86
  else:
75
87
  if verbose:
76
- _LOGGER.info(f"Object of type '{type(obj)}' saved to '{file_path}'")
88
+ if isinstance(obj, _SIMPLE_TYPES):
89
+ _LOGGER.info(f"Object of type '{type(obj)}' saved to '{file_path}'")
90
+ else:
91
+ _LOGGER.info(f"Object '{obj}' saved to '{file_path}'")
92
+
77
93
  return None
78
94
 
79
95
 
@@ -123,9 +139,13 @@ def deserialize_object(
123
139
  raise TypeError()
124
140
 
125
141
  if verbose:
126
- _LOGGER.info(f"Loaded object of type '{type(obj)}' from '{true_filepath}'.")
142
+ # log special objects
143
+ if isinstance(obj, _SIMPLE_TYPES):
144
+ _LOGGER.info(f"Loaded object of type '{type(obj)}' from '{true_filepath}'.")
145
+ else:
146
+ _LOGGER.info(f"Loaded object '{obj}' from '{true_filepath}'.")
127
147
 
128
- return obj
148
+ return obj # type: ignore
129
149
 
130
150
 
131
151
  def serialize_schema(schema: FeatureSchema, file_path: Path):