scitex_ml.classification.reporters.reporter_utils.storage

Functions

create_directory_structure_lazy(base_dir)

Create directory structure mapping without actually creating directories.

save_metric(metric_value, path[, fold, ...])

Improved function to save individual metrics with precision control.

Classes

MetricStorage(base_dir[, precision, verbose])

Enhanced storage handler with lazy creation and precision control.

class scitex_ml.classification.reporters.reporter_utils.storage.MetricStorage(base_dir, precision=3, verbose=True)[source]

Enhanced storage handler with lazy creation and precision control.

Features: - Creates directories only when actually needed - Rounds numerical values to specified precision - Graceful error handling with informative messages - Supports all standard data formats

__init__(base_dir, precision=3, verbose=True)[source]

Initialize storage with base directory and precision.

Parameters:
  • base_dir (Union[str, Path]) – Base directory for saving files

  • precision (int, default 3) – Number of decimal places for numerical outputs

save(data, relative_path, verbose=True, **kwargs)[source]

Save data with lazy directory creation and precision control.

Uses scitex_io.save for all file operations to ensure consistency.

Parameters:
  • data (Any) – Data to save

  • relative_path (Union[str, Path]) – Path relative to base_dir

  • verbose (bool, optional) – Print save confirmation

  • **kwargs (dict) – Additional keyword arguments passed to scitex_io.save (e.g., index=True for CSV)

Returns:

Absolute path to saved file

Return type:

Path

scitex_ml.classification.reporters.reporter_utils.storage.save_metric(metric_value, path, fold=None, precision=4)[source]

Improved function to save individual metrics with precision control.

Parameters:
  • metric_value (Any) – Metric value to save

  • path (Union[str, Path]) – Output path

  • fold (int, optional) – Fold index to include in metadata

  • precision (int, default 4) – Number of decimal places

Returns:

Path to saved file

Return type:

Path

scitex_ml.classification.reporters.reporter_utils.storage.create_directory_structure_lazy(base_dir)[source]

Create directory structure mapping without actually creating directories.

This returns paths that can be created later when actually needed.

Parameters:

base_dir (Union[str, Path]) – Base directory

Returns:

Mapping of directory types to paths

Return type:

Dict[str, Path]