Commit 1179e38f authored by v.gramlich1's avatar v.gramlich1
Browse files

Plot Oversampling plots with bin_edges_retransformed

parent 202af052
Pipeline #81980 failed with stages
in 9 minutes and 46 seconds
......@@ -23,7 +23,7 @@ from mlair.plotting.abstract_plot_class import AbstractPlotClass
@TimeTrackingWrapper
class PlotOversampling(AbstractPlotClass):
def __init__(self, data, bin_edges, oversampling_rates, plot_folder: str = ".",
def __init__(self, data, bin_edges, bin_edges_retransformed, oversampling_rates, plot_folder: str = ".",
plot_names=["oversampling_histogram", "oversampling_density_histogram", "oversampling_rates",
"oversampling_rates_deviation"]):
......@@ -31,10 +31,10 @@ class PlotOversampling(AbstractPlotClass):
Y_hist, Y_extreme_hist, Y_hist_dens, Y_extreme_hist_dens = self._calculate_hist(data, bin_edges)
real_oversampling = Y_extreme_hist / Y_hist
self._plot_oversampling_histogram(Y_hist, Y_extreme_hist, bin_edges)
self._plot_oversampling_histogram(Y_hist, Y_extreme_hist, bin_edges_retransformed)
self._save()
self.plot_name = plot_names[1]
self._plot_oversampling_histogram(Y_hist_dens, Y_extreme_hist_dens, bin_edges)
self._plot_oversampling_histogram(Y_hist_dens, Y_extreme_hist_dens, bin_edges_retransformed)
self._save()
self.plot_name = plot_names[2]
self._plot_oversampling_rates(oversampling_rates, real_oversampling)
......
......@@ -356,8 +356,9 @@ class PostProcessing(RunEnvironment):
if (self.data_store.get('oversampling_method')=='bin_oversampling') and (
"PlotOversampling" in plot_list):
bin_edges = self.data_store.get('oversampling_bin_edges')
bin_edges_retransformed = self.data_store.get('oversampling_bin_edges_retransformed')
oversampling_rates = self.data_store.get('oversampling_rates_capped', 'train')
PlotOversampling(self.train_data, bin_edges, oversampling_rates, plot_folder=self.plot_path)
PlotOversampling(self.train_data, bin_edges, bin_edges_retransformed, oversampling_rates, plot_folder=self.plot_path)
except Exception as e:
logging.error(f"Could not create plot OversamplingPlots due to the following error: {e}")
......
......@@ -99,10 +99,15 @@ class PreProcessing(RunEnvironment):
# Get Oversampling rates (with and without cap)
oversampling_rates = 1 / histogram
oversampling_rates_capped = np.minimum(oversampling_rates, rates_cap)
# Get transformer variables
o3_mean = self.data_store.get("transformation")[0]["o3"]["mean"].values
o3_std = self.data_store.get("transformation")[0]["o3"]["std"].values
bin_edges_retransformed = np.floor(bin_edges*o3_std+o3_mean)
# Add to datastore
self.data_store.set('oversampling_rates', oversampling_rates, 'train')
self.data_store.set('oversampling_rates_capped', oversampling_rates_capped, 'train')
self.data_store.set('oversampling_bin_edges', bin_edges)
self.data_store.set('oversampling_bin_edges_retransformed', bin_edges_retransformed)
#Y = None
#Y_extreme = None
for station in data:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment