nh_results_ensemble module
Utility script to average the predictions of several runs.
- neuralhydrology.utils.nh_results_ensemble.create_results_ensemble(run_dirs: List[Path], best_k: int = None, metrics: List[str] = None, period: str = 'test', epoch: int = None) dict
Average the predictions of several runs for the specified period and calculate new metrics.
If best_k is provided, only the k runs with the best validation NSE will be used in the generated ensemble.
- Parameters:
run_dirs (List[Path]) – List of directories of the runs to be merged
best_k (int, optional) – If provided, will only merge the k best runs based on validation NSE.
metrics (List[str], optional) – Use this parameter to override the metrics from the config files in the run directories.
period ({'test', 'validation', 'train'}, optional) – One of train, val, test. If best_k is used, only ‘test’ is allowed. The run_directories must contain results files for the specified period.
epoch (int, optional) – If provided, will ensemble the model predictions of this epoch otherwise of the last epoch
- Returns:
Dictionary of ensemble predictions and metrics per basin and frequency.
- Return type:
dict