dragon-ml-toolbox 3.10.0__tar.gz → 3.10.2__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-3.10.0/dragon_ml_toolbox.egg-info → dragon_ml_toolbox-3.10.2}/PKG-INFO +1 -1
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2/dragon_ml_toolbox.egg-info}/PKG-INFO +1 -1
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/GUI_tools.py +82 -15
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ensemble_learning.py +3 -3
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/pyproject.toml +1 -1
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/LICENSE +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/LICENSE-THIRD-PARTY.md +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/README.md +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/SOURCES.txt +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/dependency_links.txt +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/requires.txt +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/top_level.txt +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ETL_engineering.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/MICE_imputation.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ML_callbacks.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ML_evaluation.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ML_trainer.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/ML_tutorial.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/PSO_optimization.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/RNN_forecast.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/VIF_factor.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/__init__.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/_pytorch_models.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/data_exploration.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/datasetmaster.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/handle_excel.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/keys.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/logger.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/path_manager.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/ml_tools/utilities.py +0 -0
- {dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/setup.cfg +0 -0
|
@@ -389,23 +389,73 @@ class BaseFeatureHandler(ABC):
|
|
|
389
389
|
|
|
390
390
|
Should return a dictionary mapping each GUI input name to its type ('continuous' or 'categorical').
|
|
391
391
|
|
|
392
|
+
_Example:_
|
|
392
393
|
```python
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
{
|
|
395
|
+
'Temperature': 'continuous',
|
|
396
|
+
'Material Type': 'categorical'
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
"""
|
|
400
|
+
pass
|
|
401
|
+
|
|
402
|
+
@property
|
|
403
|
+
@abstractmethod
|
|
404
|
+
def map_gui_to_real(self) -> Dict[str,str]:
|
|
405
|
+
"""
|
|
406
|
+
Must be implemented by the subclass.
|
|
407
|
+
|
|
408
|
+
Should return a dictionary mapping each GUI continuous feature name to its expected model feature name.
|
|
409
|
+
|
|
410
|
+
_Example:_
|
|
411
|
+
```python
|
|
412
|
+
{
|
|
413
|
+
'Temperature (K)': 'temperature_k',
|
|
414
|
+
'Pressure (Pa)': 'pressure_pa'
|
|
415
|
+
}
|
|
395
416
|
```
|
|
396
417
|
"""
|
|
397
418
|
pass
|
|
398
419
|
|
|
399
420
|
@abstractmethod
|
|
400
|
-
def process_categorical(self,
|
|
421
|
+
def process_categorical(self, gui_feature_name: str, chosen_value: Any) -> Dict[str, float]:
|
|
401
422
|
"""
|
|
402
423
|
Must be implemented by the subclass.
|
|
403
424
|
|
|
404
|
-
Should take a GUI categorical feature name and its chosen value, and return a dictionary mapping the one-hot-encoded feature names to their
|
|
425
|
+
Should take a GUI categorical feature name and its chosen value, and return a dictionary mapping the one-hot-encoded/binary real feature names to their
|
|
405
426
|
float values (as expected by the inference model).
|
|
427
|
+
|
|
428
|
+
_Example:_
|
|
429
|
+
```python
|
|
430
|
+
# GUI input: "Material Type"
|
|
431
|
+
# GUI values: "Steel", "Aluminum", "Titanium"
|
|
432
|
+
{
|
|
433
|
+
"is_steel": 0,
|
|
434
|
+
"is_aluminum": 1,
|
|
435
|
+
"is_titanium": 0,
|
|
436
|
+
}
|
|
437
|
+
```
|
|
406
438
|
"""
|
|
407
439
|
pass
|
|
408
|
-
|
|
440
|
+
|
|
441
|
+
def _process_continuous(self, gui_feature_name: str, chosen_value: Any) -> Tuple[str, float]:
|
|
442
|
+
"""
|
|
443
|
+
Maps GUI names to model expected names and casts the value to float.
|
|
444
|
+
|
|
445
|
+
Should not be overridden by subclasses.
|
|
446
|
+
"""
|
|
447
|
+
try:
|
|
448
|
+
real_name = self.map_gui_to_real[gui_feature_name]
|
|
449
|
+
float_value = float(chosen_value)
|
|
450
|
+
except KeyError as e:
|
|
451
|
+
_LOGGER.error(f"No matching name for '{gui_feature_name}'. Check the 'map_gui_to_real' implementation.")
|
|
452
|
+
raise e
|
|
453
|
+
except (ValueError, TypeError) as e2:
|
|
454
|
+
_LOGGER.error(f"Invalid number conversion for '{chosen_value}' of '{gui_feature_name}'.")
|
|
455
|
+
raise e2
|
|
456
|
+
else:
|
|
457
|
+
return real_name, float_value
|
|
458
|
+
|
|
409
459
|
def __call__(self, window_values: Dict[str, Any]) -> np.ndarray:
|
|
410
460
|
"""
|
|
411
461
|
Performs the full vector preparation, returning a 1D numpy array.
|
|
@@ -416,16 +466,17 @@ class BaseFeatureHandler(ABC):
|
|
|
416
466
|
processed_features: Dict[str, float] = {}
|
|
417
467
|
for gui_name, feature_type in self.gui_input_map.items():
|
|
418
468
|
chosen_value = window_values.get(gui_name)
|
|
419
|
-
|
|
469
|
+
|
|
470
|
+
# value validation
|
|
420
471
|
if chosen_value is None or str(chosen_value) == '':
|
|
421
472
|
raise ValueError(f"GUI input '{gui_name}' is missing a value.")
|
|
422
473
|
|
|
474
|
+
# process continuous
|
|
423
475
|
if feature_type == 'continuous':
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
476
|
+
mapped_name, float_value = self._process_continuous(gui_name, chosen_value)
|
|
477
|
+
processed_features[mapped_name] = float_value
|
|
478
|
+
|
|
479
|
+
# process categorical
|
|
429
480
|
elif feature_type == 'categorical':
|
|
430
481
|
feature_dict = self.process_categorical(gui_name, chosen_value)
|
|
431
482
|
processed_features.update(feature_dict)
|
|
@@ -446,18 +497,34 @@ class BaseFeatureHandler(ABC):
|
|
|
446
497
|
return np.array(final_vector, dtype=np.float32)
|
|
447
498
|
|
|
448
499
|
|
|
449
|
-
def update_target_fields(window: sg.Window, results_dict: Dict[str, Any]):
|
|
500
|
+
def update_target_fields(window: sg.Window, results_dict: Dict[str, Any], map_model_to_gui: Optional[Dict[str,str]]):
|
|
450
501
|
"""
|
|
451
502
|
Updates the GUI's target fields with inference results.
|
|
452
503
|
|
|
453
504
|
Args:
|
|
454
505
|
window (sg.Window): The application's window object.
|
|
455
|
-
results_dict (dict): A dictionary where keys are target
|
|
506
|
+
results_dict (dict): A dictionary where keys are target names (as expected by the GUI) and values are the predicted results to update.
|
|
507
|
+
map_model_to_gui (dict | None): Map `results_dict.keys()` from model target names to GUI target names, if gui names were customized.
|
|
456
508
|
"""
|
|
457
|
-
|
|
509
|
+
if map_model_to_gui is not None:
|
|
510
|
+
# Validation
|
|
511
|
+
if len(map_model_to_gui) != len(results_dict):
|
|
512
|
+
_LOGGER.error(f"Expected a mapping for {len(results_dict)} targets, but received {len(map_model_to_gui)} target map names.")
|
|
513
|
+
raise ValueError
|
|
514
|
+
|
|
515
|
+
# new dictionary with GUI keys and corresponding result values
|
|
516
|
+
display_dict = {
|
|
517
|
+
gui_key: results_dict[model_key]
|
|
518
|
+
for model_key, gui_key in map_model_to_gui.items()
|
|
519
|
+
}
|
|
520
|
+
else:
|
|
521
|
+
# If no map is provided, use given result keys
|
|
522
|
+
display_dict = results_dict
|
|
523
|
+
|
|
524
|
+
for key, result in display_dict.items():
|
|
458
525
|
# Format numbers to 2 decimal places, leave other types as-is
|
|
459
526
|
display_value = f"{result:.2f}" if isinstance(result, (int, float)) else result
|
|
460
|
-
window[
|
|
527
|
+
window[key].update(display_value) # type: ignore
|
|
461
528
|
|
|
462
529
|
|
|
463
530
|
def info():
|
|
@@ -973,9 +973,9 @@ class InferenceHandler:
|
|
|
973
973
|
verbose=self.verbose,
|
|
974
974
|
raise_on_error=True) # type: ignore
|
|
975
975
|
|
|
976
|
-
model: Any = full_object[
|
|
977
|
-
target_name: str = full_object[
|
|
978
|
-
feature_names_list: List[str] = full_object[
|
|
976
|
+
model: Any = full_object[ModelSaveKeys.MODEL]
|
|
977
|
+
target_name: str = full_object[ModelSaveKeys.TARGET]
|
|
978
|
+
feature_names_list: List[str] = full_object[ModelSaveKeys.FEATURES]
|
|
979
979
|
|
|
980
980
|
# Check that feature names match
|
|
981
981
|
if self._feature_names is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/dragon_ml_toolbox.egg-info/requires.txt
RENAMED
|
File without changes
|
{dragon_ml_toolbox-3.10.0 → dragon_ml_toolbox-3.10.2}/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
|