dragon-ml-toolbox 12.3.0__tar.gz → 12.5.0__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 dragon-ml-toolbox might be problematic. Click here for more details.
- {dragon_ml_toolbox-12.3.0/dragon_ml_toolbox.egg-info → dragon_ml_toolbox-12.5.0}/PKG-INFO +1 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0/dragon_ml_toolbox.egg-info}/PKG-INFO +1 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/custom_logger.py +1 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/data_exploration.py +11 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/serde.py +37 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/pyproject.toml +1 -1
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/LICENSE +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/LICENSE-THIRD-PARTY.md +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/README.md +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/SOURCES.txt +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/dependency_links.txt +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/requires.txt +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/top_level.txt +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ETL_cleaning.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ETL_engineering.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/GUI_tools.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/MICE_imputation.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_callbacks.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_datasetmaster.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_evaluation.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_evaluation_multi.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_inference.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_models.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_optimization.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_scaler.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_simple_optimization.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_trainer.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ML_utilities.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/PSO_optimization.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/RNN_forecast.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/SQL.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/VIF_factor.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/__init__.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/_logger.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/_script_info.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/constants.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ensemble_evaluation.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ensemble_inference.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/ensemble_learning.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/handle_excel.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/keys.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/math_utilities.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/optimization_tools.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/path_manager.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/ml_tools/utilities.py +0 -0
- {dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/setup.cfg +0 -0
|
@@ -172,7 +172,7 @@ def load_list_strings(text_file: Union[str,Path], verbose: bool=True) -> list[st
|
|
|
172
172
|
raise ValueError()
|
|
173
173
|
|
|
174
174
|
if verbose:
|
|
175
|
-
_LOGGER.info(f"
|
|
175
|
+
_LOGGER.info(f"Loaded '{target_path.name}' as list of strings.")
|
|
176
176
|
|
|
177
177
|
return loaded_strings
|
|
178
178
|
|
|
@@ -891,7 +891,8 @@ def standardize_percentages(
|
|
|
891
891
|
df: pd.DataFrame,
|
|
892
892
|
columns: list[str],
|
|
893
893
|
treat_one_as_proportion: bool = True,
|
|
894
|
-
round_digits: int = 2
|
|
894
|
+
round_digits: int = 2,
|
|
895
|
+
verbose: bool=True
|
|
895
896
|
) -> pd.DataFrame:
|
|
896
897
|
"""
|
|
897
898
|
Standardizes numeric columns containing mixed-format percentages.
|
|
@@ -932,6 +933,8 @@ def standardize_percentages(
|
|
|
932
933
|
|
|
933
934
|
# Otherwise, the value is assumed to be a correctly formatted percentage
|
|
934
935
|
return x
|
|
936
|
+
|
|
937
|
+
fixed_columns: list[str] = list()
|
|
935
938
|
|
|
936
939
|
for col in columns:
|
|
937
940
|
# --- Robustness Checks ---
|
|
@@ -949,6 +952,13 @@ def standardize_percentages(
|
|
|
949
952
|
|
|
950
953
|
# Round the result
|
|
951
954
|
df_copy[col] = df_copy[col].round(round_digits)
|
|
955
|
+
|
|
956
|
+
fixed_columns.append(col)
|
|
957
|
+
|
|
958
|
+
if verbose:
|
|
959
|
+
_LOGGER.info(f"Columns standardized:")
|
|
960
|
+
for fixed_col in fixed_columns:
|
|
961
|
+
print(f" '{fixed_col}'")
|
|
952
962
|
|
|
953
963
|
return df_copy
|
|
954
964
|
|
|
@@ -9,12 +9,13 @@ from ._logger import _LOGGER
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
__all__ = [
|
|
12
|
+
"serialize_object_filename",
|
|
12
13
|
"serialize_object",
|
|
13
14
|
"deserialize_object",
|
|
14
15
|
]
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
def
|
|
18
|
+
def serialize_object_filename(obj: Any, save_dir: Union[str,Path], filename: str, verbose: bool=True, raise_on_error: bool=False) -> None:
|
|
18
19
|
"""
|
|
19
20
|
Serializes a Python object using joblib; suitable for Python built-ins, numpy, and pandas.
|
|
20
21
|
|
|
@@ -40,6 +41,41 @@ def serialize_object(obj: Any, save_dir: Union[str,Path], filename: str, verbose
|
|
|
40
41
|
_LOGGER.info(f"Object of type '{type(obj)}' saved to '{full_path}'")
|
|
41
42
|
return None
|
|
42
43
|
|
|
44
|
+
|
|
45
|
+
def serialize_object(obj: Any, file_path: Path, verbose: bool = True, raise_on_error: bool = False) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Serializes a Python object using joblib to a specific file path.
|
|
48
|
+
|
|
49
|
+
Suitable for Python built-ins, numpy, and pandas.
|
|
50
|
+
|
|
51
|
+
Parameters:
|
|
52
|
+
obj (Any) : The Python object to serialize.
|
|
53
|
+
file_path (Path) : The full file path to save the object to.
|
|
54
|
+
'.joblib' extension will be appended if missing.
|
|
55
|
+
raise_on_error (bool) : If True, raises exceptions on failure.
|
|
56
|
+
"""
|
|
57
|
+
try:
|
|
58
|
+
# Ensure the extension is correct
|
|
59
|
+
if file_path.suffix != '.joblib':
|
|
60
|
+
file_path = file_path.with_suffix(file_path.suffix + '.joblib')
|
|
61
|
+
|
|
62
|
+
# Ensure the parent directory exists
|
|
63
|
+
_save_dir = make_fullpath(file_path.parent, make=True, enforce="directory")
|
|
64
|
+
|
|
65
|
+
# Dump the object
|
|
66
|
+
joblib.dump(obj, file_path)
|
|
67
|
+
|
|
68
|
+
except (IOError, OSError, TypeError, TerminatedWorkerError) as e:
|
|
69
|
+
_LOGGER.error(f"Failed to serialize object of type '{type(obj)}' to '{file_path}'. Error: {e}")
|
|
70
|
+
if raise_on_error:
|
|
71
|
+
raise e
|
|
72
|
+
return None
|
|
73
|
+
else:
|
|
74
|
+
if verbose:
|
|
75
|
+
_LOGGER.info(f"Object of type '{type(obj)}' saved to '{file_path}'")
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
|
|
43
79
|
# Define a TypeVar to link the expected type to the return type of deserialization
|
|
44
80
|
T = TypeVar('T')
|
|
45
81
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/requires.txt
RENAMED
|
File without changes
|
{dragon_ml_toolbox-12.3.0 → dragon_ml_toolbox-12.5.0}/dragon_ml_toolbox.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|