Command-Line Interface
The LoS Estimator can be run directly from the command line using the module entry point or by calling the provided analysis script.
Basic Usage
Run with default configuration:
python -m los_estimator
Run with a custom configuration file:
python -m los_estimator --config_file path/to/config.toml
Run with base config and selective overrides:
python -m los_estimator --config_file los_estimator/default_config.toml --overwrite_config_file los_estimator/overwrite_config.toml
Arguments
--config_file PATHPath to a complete configuration file (TOML format). If not provided, the default configuration at
los_estimator/default_config.tomlis used.--overwrite_config_file PATHPath to a partial configuration file that overrides specific settings in the base configuration. Useful for testing different model parameters without creating a full new config file.
Configuration Files
Configuration is managed via TOML files. The package includes:
default_config.toml: Default settings for model fitting, data paths, and visualization.
overwrite_config.toml: Sample overrides for common adjustments.
Key Configuration Sections
- data_config
icu_file: Path to ICU occupancy data CSV.los_file: Path to hospital LOS data CSV.start_dayandend_day: Time range for analysis.
- model_config
kernel_width: Width of distribution kernel in days (default: 120).train_width: Width of training window in days (default: 102).test_width: Width of test window in days (default: 21).step: Step size for sliding windows (default: 7).distributions: List of distributions to fit (e.g.,["lognorm", "gaussian", "linear"]).error_fun: Error function for optimization ("mse","mae", etc.).
- debug_config
one_window: Fit only the first window (bool).less_windows: Reduce windows to ~3 for quick testing (bool).less_distros: Test only linear and compartmental (bool).only_linear: Fit only linear models (bool).
- visualization_config
show_figures: Display plots interactively (bool).save_figures: Save plots to disk (bool).figsize: Figure dimensions as[width, height].
- animation_config
show_figures: Display animations interactively (bool).save_figures: Save animations as GIFs (bool).
Example: Quick Test Run
For rapid prototyping, enable debug flags in your config or override:
# overwrite_config.toml
[debug_config]
less_windows = true
less_distros = true
Then run:
python -m los_estimator --overwrite_config_file overwrite_config.toml
This limits fitting to ~3 windows and 2 distributions, completing in seconds.
Alternative: Using run_analysis.py
A convenience script is provided:
python run_analysis.py
This script applies the same analysis pipeline using configurations from the package. Edit run_analysis.py directly to adjust settings programmatically if preferred.
Output Structure
See Output Format for complete documentation of all output artifacts.