config

Model configuration for LOS Estimator.

class los_estimator.config.AnimationConfig(show_figures: bool = False, save_figures: bool = True, generate_gif: bool = True, short_distro_names: ~typing.List[~typing.Tuple[str, str]] = <factory>, train_error_lim: str | float = 'auto', test_error_lim: str | float = 'auto')

Configuration for animation generation and display.

Controls how animations are created and displayed, including naming conventions and debugging options for animation generation.

show_figures

Whether to display animations when created.

Type:

bool

save_figures

Whether to save animation files to disk.

Type:

bool

generate_gif

Whether to generate GIF animations.

Type:

bool

short_distro_names

Short name replacements for display.

Type:

List[Tuple[str, str]]

train_error_lim

Y-limit for train error plots or “auto”.

Type:

Union[str, float]

test_error_lim

Y-limit for test error plots or “auto”.

Type:

Union[str, float]

class los_estimator.config.DataConfig(icu_file: str, los_file: str | None = None, start_day: str | None = None, end_day: str | None = None, init_params_file: str | None = None)

Configuration for data loading and processing.

Specifies file paths and date ranges for loading hospital data required for length of stay analysis.

icu_file

Path to ICU occupancy time series data.

Type:

str

los_file

Path to length of stay reference data.

Type:

str

init_params_file

Path to initial parameter configuration.

Type:

str

start_day

Start date for analysis period.

Type:

str

end_day

End date for analysis period.

Type:

str

class los_estimator.config.DebugConfig(one_window: bool = False, less_windows: bool = False, less_distros: bool = False, only_linear: bool = False)

Configuration for debugging and development options.

Contains flags to enable various debugging modes that can speed up development by reducing the scope of analysis.

one_window

Process only one time window for quick testing.

Type:

bool

less_windows

Process fewer time windows than normal.

Type:

bool

less_distros

Test with fewer distribution types.

Type:

bool

only_linear

Use only linear distribution for testing.

Type:

bool

class los_estimator.config.ModelConfig(kernel_width: int = 120, train_width: int = 102, test_width: int = 21, step: int = 7, error_fun: str = 'mse', reuse_last_parametrization: bool = True, iterative_kernel_fit: bool = True, distributions: ~typing.List[str] = <factory>, optimizer: str = 'L-BFGS-B', run_name: str = '')

Configuration for model fitting parameters.

Contains all parameters related to the length of stay estimation model including kernel settings, data windowing, and optimization options.

kernel_width

Width of the distribution kernel in days.

Type:

int

train_width

Width of training window in days. Has to be chosen larger than the kernel width, to deal with left edge case.

Type:

int

test_width

Width of test window in days.

Type:

int

step

Step size for sliding window analysis.

Type:

int

error_fun

Error function to use for optimization.

Type:

str

reuse_last_parametrization

Reuse parameter fit from the previous window.

Type:

bool

iterative_kernel_fit

Enable iterative fitting of kernels.

Type:

bool

distributions

Candidate distribution names to try.

Type:

List[str]

run_name

Optional label to tag a run.

Type:

str

ideas

Scratchpad for experimental options.

Type:

types.SimpleNamespace

class los_estimator.config.OutputFolderConfig(base: str, run_name: str)

Configuration for output folder structure.

Manages the organization of output files including results, figures, animations, and metrics in a structured directory hierarchy.

base

Base directory for all outputs.

Type:

str

run_name

Name of the specific analysis run.

Type:

str

results

Path to the run’s root results folder.

Type:

str

figures

Path to stored figures.

Type:

str

animation

Path to stored animations.

Type:

str

metrics

Path to stored metrics.

Type:

str

model_data

Path to serialized model data.

Type:

str

build()

Build the output directory structure.

Creates the full paths for results, figures, animation, and metrics subdirectories based on the base path and run name.

class los_estimator.config.VisualizationConfig(save_figures: bool = True, show_figures: bool = True, xlims: ~typing.Tuple[int, int] = (-30, 725), figsize: ~typing.Tuple[int, int] = (12, 8), style: str = 'seaborn-v0_8', colors: ~typing.List[str] = <factory>, savefig_dpi: int = 300, figure_dpi: int = 100)

Configuration for output and visualization.

Controls all aspects of plot generation including figure size, styling, colors, and output quality settings.

save_figures

Whether to save plots to files.

Type:

bool

show_figures

Whether to display plots on screen.

Type:

bool

xlims

X-axis limits for time series plots.

Type:

Tuple[int, int]

figsize

Default figure size in inches.

Type:

Tuple[int, int]

style

Matplotlib style to use for plots.

Type:

str

colors

Custom color palette for plots.

Type:

List[str]

savefig_facecolor

Background color for saved figures.

Type:

str

savefig_dpi

DPI for saved figure files.

Type:

int

figure_dpi

DPI for displayed figures.

Type:

int

class los_estimator.config.VisualizationContext(xtick_pos: Tuple = (), xtick_label: Tuple = (), real_los: Tuple = (), xlims: Tuple = (-30, 725), results_folder: str = '', figures_folder: str = '', animation_folder: str = '')

Runtime context for visualization components.

Stores runtime information needed for generating consistent visualizations across different components, including axis formatting and folder paths.

xtick_pos

X-axis tick positions for time series plots.

Type:

Tuple

xtick_label

X-axis tick labels for time series plots.

Type:

Tuple

real_los

Real length of stay data for reference.

Type:

Tuple

xlims

X-axis limits for plots.

Type:

Tuple

results_folder

Path to results output folder.

Type:

str

figures_folder

Path to figures output folder.

Type:

str

animation_folder

Path to animation output folder.

Type:

str

los_estimator.config.load_configurations(path)

Load configurations from a TOML file.

Reads a TOML configuration file and converts it to appropriate configuration objects based on registered configuration types.

Parameters:

path (str or Path) – Path to the TOML configuration file.

Returns:

Dictionary mapping configuration names to configuration objects.

Return type:

dict

los_estimator.config.save_configurations(path, configurations)

Save configurations to a TOML file.

Converts configuration objects to dictionaries and saves them as a TOML file for future loading.

Parameters:
  • path (str or Path) – Path where to save the TOML file.

  • configurations (list) – List of configuration objects to save.

los_estimator.config.update_configurations(base_config, override_config)

Update a loaded configuration with another.

Parameters:
  • base_config (dict) – Configuration to update (modified in place).

  • override_config (dict) – Configuration with new values to merge in.