From b3842718461a7361cc79c0b58039622920f0d8f6 Mon Sep 17 00:00:00 2001 From: leufen1 <l.leufen@fz-juelich.de> Date: Tue, 26 Oct 2021 11:30:24 +0200 Subject: [PATCH] PlotBootstrapSkillScore is now called PlotFeatureImportanceSkillScore --- mlair/configuration/defaults.py | 2 +- mlair/plotting/postprocessing_plotting.py | 12 ++++-------- mlair/run_modules/post_processing.py | 23 +++++++++++------------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/mlair/configuration/defaults.py b/mlair/configuration/defaults.py index 9b79dc6a..ca569720 100644 --- a/mlair/configuration/defaults.py +++ b/mlair/configuration/defaults.py @@ -54,7 +54,7 @@ DEFAULT_FEATURE_IMPORTANCE_N_BOOTS = 20 DEFAULT_FEATURE_IMPORTANCE_BOOTSTRAP_TYPE = "singleinput" DEFAULT_FEATURE_IMPORTANCE_BOOTSTRAP_METHOD = "shuffle" DEFAULT_PLOT_LIST = ["PlotMonthlySummary", "PlotStationMap", "PlotClimatologicalSkillScore", "PlotTimeSeries", - "PlotCompetitiveSkillScore", "PlotBootstrapSkillScore", "PlotConditionalQuantiles", + "PlotCompetitiveSkillScore", "PlotFeatureImportanceSkillScore", "PlotConditionalQuantiles", "PlotAvailability", "PlotAvailabilityHistogram", "PlotDataHistogram", "PlotPeriodogram", "PlotSampleUncertaintyFromBootstrap"] DEFAULT_SAMPLING = "daily" diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index c95afea6..d9551815 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -591,14 +591,9 @@ class PlotCompetitiveSkillScore(AbstractPlotClass): # pragma: no cover @TimeTrackingWrapper -class PlotBootstrapSkillScore(AbstractPlotClass): # pragma: no cover +class PlotFeatureImportanceSkillScore(AbstractPlotClass): # pragma: no cover """ - Create plot of climatological skill score after Murphy (1988) as box plot over all stations. - - A forecast time step (called "ahead") is separately shown to highlight the differences for each prediction time - step. Either each single term is plotted (score_only=False) or only the resulting scores CASE I to IV are displayed - (score_only=True, default). Y-axis is adjusted following the data and not hard coded. The plot is saved under - plot_folder path with name skill_score_clim_{extra_name_tag}{model_setup}.pdf and resolution of 500dpi. + Create plot of feature importance analysis. By passing a list `separate_vars` containing variable names, a second plot is created showing the `separate_vars` and the remaining variables side by side with different scaling. @@ -757,7 +752,8 @@ class PlotBootstrapSkillScore(AbstractPlotClass): # pragma: no cover data_second = self._select_data(df=data, variables=remaining_vars, column_name=self._x_name) fig, ax = plt.subplots(nrows=1, ncols=2, gridspec_kw={'width_ratios': [len(separate_vars), - len(remaining_vars)]}) + len(remaining_vars)]}, + figsize=(len(remaining_vars),len(remaining_vars)/2.)) if len(separate_vars) > 1: first_box_width = .8 else: diff --git a/mlair/run_modules/post_processing.py b/mlair/run_modules/post_processing.py index 0c516242..64ac9805 100644 --- a/mlair/run_modules/post_processing.py +++ b/mlair/run_modules/post_processing.py @@ -22,7 +22,7 @@ from mlair.helpers import TimeTracking, statistics, extract_value, remove_items, from mlair.model_modules.linear_model import OrdinaryLeastSquaredModel from mlair.model_modules import AbstractModelClass from mlair.plotting.postprocessing_plotting import PlotMonthlySummary, PlotClimatologicalSkillScore, \ - PlotCompetitiveSkillScore, PlotTimeSeries, PlotBootstrapSkillScore, PlotConditionalQuantiles, \ + PlotCompetitiveSkillScore, PlotTimeSeries, PlotFeatureImportanceSkillScore, PlotConditionalQuantiles, \ PlotSeparationOfScales, PlotSampleUncertaintyFromBootstrap from mlair.plotting.data_insight_plotting import PlotStationMap, PlotAvailability, PlotAvailabilityHistogram, \ PlotPeriodogram, PlotDataHistogram @@ -471,22 +471,21 @@ class PostProcessing(RunEnvironment): f"\n{sys.exc_info()[0]}\n{sys.exc_info()[1]}\n{sys.exc_info()[2]}") try: - if (self.feature_importance_skill_scores is not None) and ("PlotBootstrapSkillScore" in plot_list): + if (self.feature_importance_skill_scores is not None) and ("PlotFeatureImportanceSkillScore" in plot_list): for boot_type, boot_data in self.feature_importance_skill_scores.items(): for boot_method, boot_skill_score in boot_data.items(): try: - #todo rename plot name - #todo check if plot works properly - PlotBootstrapSkillScore(boot_skill_score, plot_folder=self.plot_path, - model_setup=self.forecast_indicator, sampling=self._sampling, - ahead_dim=self.ahead_dim, separate_vars=to_list(self.target_var), - bootstrap_type=boot_type, bootstrap_method=boot_method) + PlotFeatureImportanceSkillScore( + boot_skill_score, plot_folder=self.plot_path, model_setup=self.forecast_indicator, + sampling=self._sampling, ahead_dim=self.ahead_dim, + separate_vars=to_list(self.target_var), bootstrap_type=boot_type, + bootstrap_method=boot_method) except Exception as e: - logging.error(f"Could not create plot PlotBootstrapSkillScore ({boot_type}, {boot_method}) " - f"due to the following error:\n{sys.exc_info()[0]}\n{sys.exc_info()[1]}\n" - f"{sys.exc_info()[2]}") + logging.error(f"Could not create plot PlotFeatureImportanceSkillScore ({boot_type}, " + f"{boot_method}) due to the following error:\n{sys.exc_info()[0]}\n" + f"{sys.exc_info()[1]}\n{sys.exc_info()[2]}") except Exception as e: - logging.error(f"Could not create plot PlotBootstrapSkillScore due to the following error: {e}") + logging.error(f"Could not create plot PlotFeatureImportanceSkillScore due to the following error: {e}") try: if "PlotConditionalQuantiles" in plot_list: -- GitLab