Utilities
Contains utility functions for calibration
This module defines various utility functions for the calibration of simulations.
- class calisim.utils.utilities.EarlyStopper(patience: int = 1, min_delta: float = 0)[source]
Early stopping for training.
- calisim.utils.utilities.calibration_func_wrapper(X: ndarray, workflow: CalibrationWorkflowBase, observed_data: DataFrame | ndarray, parameter_names: list[str], data_types: list[ParameterDataType], calibration_kwargs: dict, wrap_values: bool = False) ndarray[source]
Wrapper function for the calibration function.
- Parameters:
X (np.ndarray) – The parameter set matrix.
workflow (CalibrationWorkflowBase) – The calibration workflow.
observed_data (pd.DataFrame | np.ndarray) – The observed data.
parameter_names (list[str]) – The list of simulation parameter names.
data_types (list[ParameterDataType]) – The data types for each parameter.
calibration_kwargs (dict) – Arguments to supply to the calibration function.
wrap_values (bool) – Whether to wrap scalar values with a list. Defaults to False.
- Returns:
The simulation output data.
- Return type:
np.ndarray
- calisim.utils.utilities.create_file_path(file_path: str) str[source]
Create file path if it does not exist.
- Parameters:
file_path (str) – The file path to create.
- Returns:
The created file path.
- Return type:
str
- calisim.utils.utilities.extend_X(X: ndarray, Y_rows: int) ndarray[source]
Extend the number of rows for X with a dummy index column.
- Parameters:
X (np.ndarray) – The input matrix.
Y_rows (int)
- Returns:
The extended input matrix with a dummy column.
- Return type:
np.ndarray
- calisim.utils.utilities.get_datetime_now() str[source]
Get the current datetime for now.
- Returns:
The current datetime.
- Return type:
str