dragon-ml-toolbox 20.8.0__py3-none-any.whl → 20.9.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.
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/METADATA +1 -1
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/RECORD +11 -10
- ml_tools/ML_datasetmaster/_base_datasetmaster.py +53 -3
- ml_tools/ML_evaluation/_classification.py +17 -14
- ml_tools/ML_evaluation/_helpers.py +41 -0
- ml_tools/ML_evaluation/_regression.py +5 -0
- ml_tools/keys/_keys.py +1 -1
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/WHEEL +0 -0
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/licenses/LICENSE +0 -0
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/licenses/LICENSE-THIRD-PARTY.md +0 -0
- {dragon_ml_toolbox-20.8.0.dist-info → dragon_ml_toolbox-20.9.0.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
dragon_ml_toolbox-20.
|
|
2
|
-
dragon_ml_toolbox-20.
|
|
1
|
+
dragon_ml_toolbox-20.9.0.dist-info/licenses/LICENSE,sha256=L35WDmmLZNTlJvxF6Vy7Uy4SYNi6rCfWUqlTHpoRMoU,1081
|
|
2
|
+
dragon_ml_toolbox-20.9.0.dist-info/licenses/LICENSE-THIRD-PARTY.md,sha256=0-HBRMMgKuwtGy6nMJZvIn1fLxhx_ksyyVB2U_iyYZU,2818
|
|
3
3
|
ml_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
ml_tools/constants.py,sha256=3br5Rk9cL2IUo638eJuMOGdbGQaWssaUecYEvSeRBLM,3322
|
|
5
5
|
ml_tools/ETL_cleaning/__init__.py,sha256=gLRHF-qzwpqKTvbbn9chIQELeUDh_XGpBRX28j-5IqI,545
|
|
@@ -34,15 +34,16 @@ ml_tools/ML_configuration/_metrics.py,sha256=KJM7HQeoEmJUUUrxNa4wYf2N9NawGPJoy7A
|
|
|
34
34
|
ml_tools/ML_configuration/_models.py,sha256=lvuuqvD6DWUzOa3i06NZfrdfOi9bu2e26T_QO6BGMSw,7629
|
|
35
35
|
ml_tools/ML_configuration/_training.py,sha256=_M_TwouHFNbGrZQtQNAvyG_poSVpmN99cbyUonZsHhk,8969
|
|
36
36
|
ml_tools/ML_datasetmaster/__init__.py,sha256=UltQzuXnlXVCkD-aeA5TW4IcMVLnQf1_aglawg4WyrI,580
|
|
37
|
-
ml_tools/ML_datasetmaster/_base_datasetmaster.py,sha256=
|
|
37
|
+
ml_tools/ML_datasetmaster/_base_datasetmaster.py,sha256=IgyVzRY3mlKDyBDklawvPF9SMjZFu8T2red6M-3MlQ4,16074
|
|
38
38
|
ml_tools/ML_datasetmaster/_datasetmaster.py,sha256=Oy2UE3YJpKTaFwQF5TkQLgLB54-BFw_5b8wIPTxZIKU,19157
|
|
39
39
|
ml_tools/ML_datasetmaster/_sequence_datasetmaster.py,sha256=cW3fuILZWs-7Yuo4T2fgGfTC4vwho3Gp4ohIKJYS7O0,18452
|
|
40
40
|
ml_tools/ML_datasetmaster/_vision_datasetmaster.py,sha256=kvSqXYeNBN1JSRfSEEXYeIcsqy9HsJAl_EwFWClqlsw,67025
|
|
41
41
|
ml_tools/ML_evaluation/__init__.py,sha256=e3c8JNP0tt4Kxc7QSQpGcOgrxf8JAucH4UkJvJxUL2E,1122
|
|
42
|
-
ml_tools/ML_evaluation/_classification.py,sha256=
|
|
42
|
+
ml_tools/ML_evaluation/_classification.py,sha256=0URqIhNEgWedy-SYRmIJ2ejLKqatiuOU7qelJ6Cv3OE,33939
|
|
43
43
|
ml_tools/ML_evaluation/_feature_importance.py,sha256=mTwi3LKom_axu6UFKunELj30APDdhG9GQC2w7I9mYhI,17137
|
|
44
|
+
ml_tools/ML_evaluation/_helpers.py,sha256=kE1TSYIOAAcYI1EjdudyTfFeU47Wrl0E9eNL1EOwbKg,1217
|
|
44
45
|
ml_tools/ML_evaluation/_loss.py,sha256=1a4O25i3Ya_3naNZNL7ELLUL46BY86g1scA7d7q2UFM,3625
|
|
45
|
-
ml_tools/ML_evaluation/_regression.py,sha256=
|
|
46
|
+
ml_tools/ML_evaluation/_regression.py,sha256=UZA7_fg85ZKJQWszioWDtmkplSiXeHJk2fBYR5bRXHY,11225
|
|
46
47
|
ml_tools/ML_evaluation/_sequence.py,sha256=gUk9Uvmy7MrXkfrriMnfypkgJU5XERHdqekTa2gBaOM,8004
|
|
47
48
|
ml_tools/ML_evaluation/_vision.py,sha256=abBHQ6Z2GunHNusL3wcLgfI1FVNA6hBUBTq1eOA8FSA,11489
|
|
48
49
|
ml_tools/ML_evaluation_captum/_ML_evaluation_captum.py,sha256=6g3ymSxJGHXxwIN7WCD2Zi9zxKWEv-Qskd2cCGQQJ5Y,18439
|
|
@@ -118,7 +119,7 @@ ml_tools/ensemble_learning/_ensemble_learning.py,sha256=MHDZBR20_nStlSSeThFI3bSu
|
|
|
118
119
|
ml_tools/excel_handler/__init__.py,sha256=AaWM3n_dqBhJLTs3OEA57ex5YykKXNOwVCyHlVsdnqI,530
|
|
119
120
|
ml_tools/excel_handler/_excel_handler.py,sha256=TODudmeQgDSdxUKzLfAzizs--VL-g8WxDOfQ4sgxxLs,13965
|
|
120
121
|
ml_tools/keys/__init__.py,sha256=-0c2pmrhyfROc-oQpEjJGLBMhSagA3CyFijQaaqZRqU,399
|
|
121
|
-
ml_tools/keys/_keys.py,sha256=
|
|
122
|
+
ml_tools/keys/_keys.py,sha256=56hlyPl2VUMsq7cFFLBypWHr-JU6ehWGwZG38l6IjI0,9389
|
|
122
123
|
ml_tools/math_utilities/__init__.py,sha256=K7Obkkc4rPKj4EbRZf1BsXHfiCg7FXYv_aN9Yc2Z_Vg,400
|
|
123
124
|
ml_tools/math_utilities/_math_utilities.py,sha256=BYHIVcM9tuKIhVrkgLLiM5QalJ39zx7dXYy_M9aGgiM,9012
|
|
124
125
|
ml_tools/optimization_tools/__init__.py,sha256=KD8JXpfGuPndO4AHnjJGu6uV1GRwhOfboD0KZV45kzw,658
|
|
@@ -142,7 +143,7 @@ ml_tools/utilities/__init__.py,sha256=h4lE3SQstg-opcQj6QSKhu-HkqSbmHExsWoM9vC5D9
|
|
|
142
143
|
ml_tools/utilities/_translate.py,sha256=U8hRPa3PmTpIf9n9yR3gBGmp_hkcsjQLwjAHSHc0WHs,10325
|
|
143
144
|
ml_tools/utilities/_utility_save_load.py,sha256=EFvFaTaHahDQWdJWZr-j7cHqRbG_Xrpc96228JhV-bs,16773
|
|
144
145
|
ml_tools/utilities/_utility_tools.py,sha256=bN0J9d1S0W5wNzNntBWqDsJcEAK7-1OgQg3X2fwXns0,6918
|
|
145
|
-
dragon_ml_toolbox-20.
|
|
146
|
-
dragon_ml_toolbox-20.
|
|
147
|
-
dragon_ml_toolbox-20.
|
|
148
|
-
dragon_ml_toolbox-20.
|
|
146
|
+
dragon_ml_toolbox-20.9.0.dist-info/METADATA,sha256=ehKhp6BpCkHcZnWpcoZU53rn4T0yI0Dboq3eH2vx8LU,7888
|
|
147
|
+
dragon_ml_toolbox-20.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
148
|
+
dragon_ml_toolbox-20.9.0.dist-info/top_level.txt,sha256=wm-oxax3ciyez6VoO4zsFd-gSok2VipYXnbg3TH9PtU,9
|
|
149
|
+
dragon_ml_toolbox-20.9.0.dist-info/RECORD,,
|
|
@@ -133,7 +133,7 @@ class _BaseDatasetMaker(ABC):
|
|
|
133
133
|
|
|
134
134
|
# Get continuous feature indices *from the schema*
|
|
135
135
|
if schema.continuous_feature_names:
|
|
136
|
-
if verbose >=
|
|
136
|
+
if verbose >= 3:
|
|
137
137
|
_LOGGER.info("Getting continuous feature indices from schema.")
|
|
138
138
|
try:
|
|
139
139
|
# Convert columns to a standard list for .index()
|
|
@@ -189,7 +189,7 @@ class _BaseDatasetMaker(ABC):
|
|
|
189
189
|
# ------------------------------------------------------------------
|
|
190
190
|
|
|
191
191
|
if self.target_scaler is None:
|
|
192
|
-
if verbose >=
|
|
192
|
+
if verbose >= 3:
|
|
193
193
|
_LOGGER.info("Fitting a new DragonScaler on training targets.")
|
|
194
194
|
# Convert to float tensor for calculation
|
|
195
195
|
y_train_tensor = torch.tensor(y_train_arr, dtype=torch.float32)
|
|
@@ -202,6 +202,9 @@ class _BaseDatasetMaker(ABC):
|
|
|
202
202
|
y_val_tensor = self.target_scaler.transform(torch.tensor(y_val_arr, dtype=torch.float32))
|
|
203
203
|
y_test_tensor = self.target_scaler.transform(torch.tensor(y_test_arr, dtype=torch.float32))
|
|
204
204
|
return y_train_tensor.numpy(), y_val_tensor.numpy(), y_test_tensor.numpy()
|
|
205
|
+
|
|
206
|
+
if verbose >= 2:
|
|
207
|
+
_LOGGER.info("Target scaling transformation complete.")
|
|
205
208
|
|
|
206
209
|
return y_train_arr, y_val_arr, y_test_arr
|
|
207
210
|
|
|
@@ -214,6 +217,9 @@ class _BaseDatasetMaker(ABC):
|
|
|
214
217
|
|
|
215
218
|
@property
|
|
216
219
|
def train_dataset(self) -> Dataset:
|
|
220
|
+
"""
|
|
221
|
+
Returns the training dataset.
|
|
222
|
+
"""
|
|
217
223
|
if self._train_ds is None:
|
|
218
224
|
_LOGGER.error("Train Dataset not yet created.")
|
|
219
225
|
raise RuntimeError()
|
|
@@ -221,6 +227,9 @@ class _BaseDatasetMaker(ABC):
|
|
|
221
227
|
|
|
222
228
|
@property
|
|
223
229
|
def validation_dataset(self) -> Dataset:
|
|
230
|
+
"""
|
|
231
|
+
Returns the validation dataset.
|
|
232
|
+
"""
|
|
224
233
|
if self._val_ds is None:
|
|
225
234
|
_LOGGER.error("Validation Dataset not yet created.")
|
|
226
235
|
raise RuntimeError()
|
|
@@ -228,6 +237,9 @@ class _BaseDatasetMaker(ABC):
|
|
|
228
237
|
|
|
229
238
|
@property
|
|
230
239
|
def test_dataset(self) -> Dataset:
|
|
240
|
+
"""
|
|
241
|
+
Returns the test dataset.
|
|
242
|
+
"""
|
|
231
243
|
if self._test_ds is None:
|
|
232
244
|
_LOGGER.error("Test Dataset not yet created.")
|
|
233
245
|
raise RuntimeError()
|
|
@@ -235,30 +247,50 @@ class _BaseDatasetMaker(ABC):
|
|
|
235
247
|
|
|
236
248
|
@property
|
|
237
249
|
def feature_names(self) -> list[str]:
|
|
250
|
+
"""
|
|
251
|
+
Returns a list with the feature names.
|
|
252
|
+
"""
|
|
238
253
|
return self._feature_names
|
|
239
254
|
|
|
240
255
|
@property
|
|
241
256
|
def target_names(self) -> list[str]:
|
|
257
|
+
"""
|
|
258
|
+
Returns a list with the target names.
|
|
259
|
+
"""
|
|
242
260
|
return self._target_names
|
|
243
261
|
|
|
244
262
|
@property
|
|
245
263
|
def number_of_features(self) -> int:
|
|
264
|
+
"""
|
|
265
|
+
Returns the number of features.
|
|
266
|
+
"""
|
|
246
267
|
return len(self._feature_names)
|
|
247
268
|
|
|
248
269
|
@property
|
|
249
270
|
def number_of_targets(self) -> int:
|
|
271
|
+
"""
|
|
272
|
+
Returns the number of targets.
|
|
273
|
+
"""
|
|
250
274
|
return len(self._target_names)
|
|
251
275
|
|
|
252
276
|
@property
|
|
253
277
|
def id(self) -> Optional[str]:
|
|
278
|
+
"""
|
|
279
|
+
Returns the dataset ID if set, otherwise None.
|
|
280
|
+
"""
|
|
254
281
|
return self._id
|
|
255
282
|
|
|
256
283
|
@id.setter
|
|
257
284
|
def id(self, dataset_id: str):
|
|
258
|
-
if not isinstance(dataset_id, str):
|
|
285
|
+
if not isinstance(dataset_id, str):
|
|
286
|
+
_LOGGER.error("Dataset ID must be a string.")
|
|
287
|
+
raise ValueError()
|
|
259
288
|
self._id = dataset_id
|
|
260
289
|
|
|
261
290
|
def dataframes_info(self) -> None:
|
|
291
|
+
"""
|
|
292
|
+
Prints the shapes of the dataframes after the split.
|
|
293
|
+
"""
|
|
262
294
|
print("--- DataFrame Shapes After Split ---")
|
|
263
295
|
print(f" X_train shape: {self._X_train_shape}, y_train shape: {self._y_train_shape}")
|
|
264
296
|
print(f" X_val shape: {self._X_val_shape}, y_val shape: {self._y_val_shape}")
|
|
@@ -266,12 +298,26 @@ class _BaseDatasetMaker(ABC):
|
|
|
266
298
|
print("------------------------------------")
|
|
267
299
|
|
|
268
300
|
def save_feature_names(self, directory: Union[str, Path], verbose: bool=True) -> None:
|
|
301
|
+
"""
|
|
302
|
+
Saves the feature names to a text file.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
directory (str | Path): Directory to save the feature names.
|
|
306
|
+
verbose (bool): Whether to print log messages.
|
|
307
|
+
"""
|
|
269
308
|
save_list_strings(list_strings=self._feature_names,
|
|
270
309
|
directory=directory,
|
|
271
310
|
filename=DatasetKeys.FEATURE_NAMES,
|
|
272
311
|
verbose=verbose)
|
|
273
312
|
|
|
274
313
|
def save_target_names(self, directory: Union[str, Path], verbose: bool=True) -> None:
|
|
314
|
+
"""
|
|
315
|
+
Saves the target names to a text file.
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
directory (str | Path): Directory to save the target names.
|
|
319
|
+
verbose (bool): Whether to print log messages.
|
|
320
|
+
"""
|
|
275
321
|
save_list_strings(list_strings=self._target_names,
|
|
276
322
|
directory=directory,
|
|
277
323
|
filename=DatasetKeys.TARGET_NAMES,
|
|
@@ -281,6 +327,10 @@ class _BaseDatasetMaker(ABC):
|
|
|
281
327
|
"""
|
|
282
328
|
Saves both feature and target scalers (if they exist) to a single .pth file
|
|
283
329
|
using a dictionary structure.
|
|
330
|
+
|
|
331
|
+
Args:
|
|
332
|
+
directory (str | Path): Directory to save the scaler.
|
|
333
|
+
verbose (bool): Whether to print log messages.
|
|
284
334
|
"""
|
|
285
335
|
if self.feature_scaler is None and self.target_scaler is None:
|
|
286
336
|
_LOGGER.warning("No scalers (feature or target) were fitted. Nothing to save.")
|
|
@@ -28,6 +28,8 @@ from ..path_manager import make_fullpath, sanitize_filename
|
|
|
28
28
|
from .._core import get_logger
|
|
29
29
|
from ..keys._keys import _EvaluationConfig
|
|
30
30
|
|
|
31
|
+
from ._helpers import check_and_abbreviate_name
|
|
32
|
+
|
|
31
33
|
|
|
32
34
|
_LOGGER = get_logger("Classification Metrics")
|
|
33
35
|
|
|
@@ -85,7 +87,8 @@ def classification_metrics(save_dir: Union[str, Path],
|
|
|
85
87
|
try:
|
|
86
88
|
sorted_items = sorted(class_map.items(), key=lambda item: item[1])
|
|
87
89
|
map_labels = [item[1] for item in sorted_items]
|
|
88
|
-
|
|
90
|
+
# Abbreviate display labels if needed
|
|
91
|
+
map_display_labels = [check_and_abbreviate_name(item[0]) for item in sorted_items]
|
|
89
92
|
except Exception as e:
|
|
90
93
|
_LOGGER.warning(f"Could not parse 'class_map': {e}")
|
|
91
94
|
map_labels = None
|
|
@@ -397,6 +400,10 @@ def classification_metrics(save_dir: Union[str, Path],
|
|
|
397
400
|
# --- Step 1: Get binned data directly ---
|
|
398
401
|
# calculates reliability diagram data without needing a temporary plot
|
|
399
402
|
prob_true, prob_pred = calibration_curve(y_true_binary, y_score, n_bins=dynamic_bins)
|
|
403
|
+
|
|
404
|
+
# Anchor the plot to (0,0) and (1,1) to ensure the line spans the full diagonal
|
|
405
|
+
prob_true = np.concatenate(([0.0], prob_true, [1.0]))
|
|
406
|
+
prob_pred = np.concatenate(([0.0], prob_pred, [1.0]))
|
|
400
407
|
|
|
401
408
|
# --- Step 2: Plot ---
|
|
402
409
|
ax_cal.plot([0, 1], [0, 1], 'k--', label='Perfectly calibrated')
|
|
@@ -467,6 +474,9 @@ def multi_label_classification_metrics(
|
|
|
467
474
|
|
|
468
475
|
save_dir_path = make_fullpath(save_dir, make=True, enforce="directory")
|
|
469
476
|
|
|
477
|
+
# --- Pre-process target names for abbreviation ---
|
|
478
|
+
target_names = [check_and_abbreviate_name(name) for name in target_names]
|
|
479
|
+
|
|
470
480
|
# --- Parse Config or use defaults ---
|
|
471
481
|
if config is None:
|
|
472
482
|
# Create a default config if one wasn't provided
|
|
@@ -502,7 +512,7 @@ def multi_label_classification_metrics(
|
|
|
502
512
|
# print(overall_report)
|
|
503
513
|
overall_report_path = save_dir_path / "classification_report.txt"
|
|
504
514
|
overall_report_path.write_text(overall_report)
|
|
505
|
-
|
|
515
|
+
|
|
506
516
|
# --- Save Classification Report Heatmap (Multi-label) ---
|
|
507
517
|
try:
|
|
508
518
|
# Generate full report as dict
|
|
@@ -566,18 +576,6 @@ def multi_label_classification_metrics(
|
|
|
566
576
|
pred_i = y_pred[:, i] # Use passed-in y_pred
|
|
567
577
|
prob_i = y_prob[:, i] # Use passed-in y_prob
|
|
568
578
|
sanitized_name = sanitize_filename(name)
|
|
569
|
-
|
|
570
|
-
# if name is too long, just take the first letter of each word. Each word might be separated by space or underscore
|
|
571
|
-
if len(name) >= _EvaluationConfig.NAME_LIMIT:
|
|
572
|
-
parts = [w for w in name.replace("_", " ").split() if w]
|
|
573
|
-
abbr = "".join(p[0].upper() for p in parts)
|
|
574
|
-
# keep only alpha numeric chars
|
|
575
|
-
abbr = "".join(ch for ch in abbr if ch.isalnum())
|
|
576
|
-
if not abbr:
|
|
577
|
-
# fallback to a sanitized, truncated version of the original name
|
|
578
|
-
abbr = sanitize_filename(name)[: _EvaluationConfig.NAME_LIMIT]
|
|
579
|
-
_LOGGER.warning(f"Using abbreviated name '{abbr}' for '{name}' plots.")
|
|
580
|
-
name = abbr
|
|
581
579
|
|
|
582
580
|
# --- Save Classification Report for the label (uses y_pred) ---
|
|
583
581
|
report_text = classification_report(true_i, pred_i)
|
|
@@ -726,6 +724,11 @@ def multi_label_classification_metrics(
|
|
|
726
724
|
# Calculate calibration curve for this specific label
|
|
727
725
|
prob_true, prob_pred = calibration_curve(true_i, prob_i, n_bins=dynamic_bins)
|
|
728
726
|
|
|
727
|
+
# Anchor the plot to (0,0) and (1,1)
|
|
728
|
+
prob_true = np.concatenate(([0.0], prob_true, [1.0]))
|
|
729
|
+
prob_pred = np.concatenate(([0.0], prob_pred, [1.0]))
|
|
730
|
+
|
|
731
|
+
# Plot the calibration curve
|
|
729
732
|
ax_cal.plot([0, 1], [0, 1], 'k--', label='Perfectly calibrated')
|
|
730
733
|
ax_cal.plot(prob_pred,
|
|
731
734
|
prob_true,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from ..keys._keys import _EvaluationConfig
|
|
2
|
+
from ..path_manager import sanitize_filename
|
|
3
|
+
from .._core import get_logger
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
_LOGGER = get_logger("Metrics Helper")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def check_and_abbreviate_name(name: str) -> str:
|
|
10
|
+
"""
|
|
11
|
+
Checks if a name exceeds the NAME_LIMIT. If it does, creates an abbreviation
|
|
12
|
+
(initials of words) or truncates it if the abbreviation is empty.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
name (str): The original label or target name.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
str: The potentially abbreviated name.
|
|
19
|
+
"""
|
|
20
|
+
limit = _EvaluationConfig.NAME_LIMIT
|
|
21
|
+
|
|
22
|
+
# Strip whitespace
|
|
23
|
+
name = name.strip()
|
|
24
|
+
|
|
25
|
+
if len(name) <= limit:
|
|
26
|
+
return name
|
|
27
|
+
|
|
28
|
+
# Attempt abbreviation: First letter of each word (split by space or underscore)
|
|
29
|
+
parts = [w for w in name.replace("_", " ").split() if w]
|
|
30
|
+
abbr = "".join(p[0].upper() for p in parts)
|
|
31
|
+
|
|
32
|
+
# Keep only alphanumeric characters
|
|
33
|
+
abbr = "".join(ch for ch in abbr if ch.isalnum())
|
|
34
|
+
|
|
35
|
+
# Fallback if abbreviation failed or is empty
|
|
36
|
+
if not abbr:
|
|
37
|
+
sanitized = sanitize_filename(name)
|
|
38
|
+
abbr = sanitized[:limit]
|
|
39
|
+
|
|
40
|
+
_LOGGER.warning(f"Label '{name}' is too long. Abbreviating to '{abbr}'.")
|
|
41
|
+
return abbr
|
|
@@ -19,6 +19,8 @@ from ..path_manager import make_fullpath, sanitize_filename
|
|
|
19
19
|
from .._core import get_logger
|
|
20
20
|
from ..keys._keys import _EvaluationConfig
|
|
21
21
|
|
|
22
|
+
from ._helpers import check_and_abbreviate_name
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
_LOGGER = get_logger("Regression Metrics")
|
|
24
26
|
|
|
@@ -180,6 +182,9 @@ def multi_target_regression_metrics(
|
|
|
180
182
|
if y_true.shape[1] != len(target_names):
|
|
181
183
|
_LOGGER.error("Number of target names must match the number of columns in y_true.")
|
|
182
184
|
raise ValueError()
|
|
185
|
+
|
|
186
|
+
# --- Pre-process target names for abbreviation ---
|
|
187
|
+
target_names = [check_and_abbreviate_name(name) for name in target_names]
|
|
183
188
|
|
|
184
189
|
save_dir_path = make_fullpath(save_dir, make=True, enforce="directory")
|
|
185
190
|
metrics_summary = []
|
ml_tools/keys/_keys.py
CHANGED
|
@@ -306,7 +306,7 @@ class _EvaluationConfig:
|
|
|
306
306
|
LOSS_PLOT_LEGEND_SIZE = 24
|
|
307
307
|
# CM settings
|
|
308
308
|
CM_SIZE = (9, 8) # used for multi label binary classification confusion matrix
|
|
309
|
-
NAME_LIMIT =
|
|
309
|
+
NAME_LIMIT = 15 # max number of characters for feature/label names in plots
|
|
310
310
|
|
|
311
311
|
class _OneHotOtherPlaceholder:
|
|
312
312
|
"""Used internally by GUI_tools."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|