Skip to content
Snippets Groups Projects

Resolve "release v1.2.0"

Merged Ghost User requested to merge release_v1.2.0 into master
2 files
+ 79
19
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -113,9 +113,47 @@ class PreProcessing(RunEnvironment):
precision = 4
path = os.path.join(self.data_store.get("experiment_path"), "latex_report")
path_config.check_path_and_create(path)
set_names = ["train", "val", "test"]
df = pd.DataFrame(columns=meta_data + set_names)
for set_name in set_names:
names_of_set = ["train", "val", "test"]
df = self.create_info_df(meta_data, meta_round, names_of_set, precision)
column_format = self.create_column_format_for_tex(df)
self.save_to_tex(path=path, filename="station_sample_size.tex", column_format=column_format, df=df)
self.save_to_md(path=path, filename="station_sample_size.md", df=df)
df_nometa = df.drop(meta_data, axis=1)
self.save_to_tex(path=path, filename="station_sample_size_short.tex", column_format=column_format, df=df_nometa)
self.save_to_md(path=path, filename="station_sample_size_short.md", df=df_nometa)
# df_nometa.to_latex(os.path.join(path, "station_sample_size_short.tex"), na_rep='---',
# column_format=column_format)
df_descr = self.create_describe_df(df_nometa)
column_format = self.create_column_format_for_tex(df_descr)
self.save_to_tex(path=path, filename="station_describe_short.tex", column_format=column_format, df=df_descr)
self.save_to_md(path=path, filename="station_describe_short.md", df=df_descr)
# df_descr.to_latex(os.path.join(path, "station_describe_short.tex"), na_rep='---', column_format=column_format)
@staticmethod
def create_describe_df(df, percentiles=None, ignore_last_lines: int = 2):
if percentiles is None:
percentiles = [.05, .1, .25, .5, .75, .9, .95]
df_descr = df.iloc[:-ignore_last_lines].astype('float32').describe(
percentiles=percentiles).astype('int32')
df_descr = pd.concat([df.loc[['# Samples']], df_descr]).T
df_descr.rename(columns={"# Samples": "no. samples", "count": "no. stations"}, inplace=True)
df_descr_colnames = list(df_descr.columns)
df_descr_colnames = [df_descr_colnames[1]] + [df_descr_colnames[0]] + df_descr_colnames[2:]
df_descr = df_descr[df_descr_colnames]
return df_descr
@staticmethod
def save_to_tex(path, filename, column_format, df, na_rep='---'):
df.to_latex(os.path.join(path, filename), na_rep=na_rep, column_format=column_format)
@staticmethod
def save_to_md(path, filename, df, mode="w", encoding='utf-8', tablefmt="github"):
df.to_markdown(open(os.path.join(path, filename), mode=mode, encoding=encoding),
tablefmt=tablefmt)
def create_info_df(self, meta_data, meta_round, names_of_set, precision):
df = pd.DataFrame(columns=meta_data + names_of_set)
for set_name in names_of_set:
data = self.data_store.get("data_collection", set_name)
for station in data:
station_name = str(station.id_class)
@@ -128,22 +166,7 @@ class PreProcessing(RunEnvironment):
df.sort_index(inplace=True)
df = df.reindex(df.index.drop(["# Stations", "# Samples"]).to_list() + ["# Stations", "# Samples"], )
df.index.name = 'stat. ID'
column_format = self.create_column_format_for_tex(df)
df.to_latex(os.path.join(path, "station_sample_size.tex"), na_rep='---', column_format=column_format)
df.to_markdown(open(os.path.join(path, "station_sample_size.md"), mode="w", encoding='utf-8'), tablefmt="github")
df_nometa = df.drop(meta_data, axis=1)
df_nometa.to_latex(os.path.join(path, "station_sample_size_short.tex"), na_rep='---',
column_format=column_format)
df_descr = df_nometa.iloc[:-2].astype('float32').describe(
percentiles=[.05, .1, .25, .5, .75, .9, .95]).astype('int32')
df_descr = pd.concat([df_nometa.loc[['# Samples']], df_descr]).T
df_descr.rename(columns={"# Samples": "no. samples", "count": "no. stations"}, inplace=True)
df_descr_colnames = list(df_descr.columns)
df_descr_colnames = [df_descr_colnames[1]] + [df_descr_colnames[0]] + df_descr_colnames[2:]
df_descr = df_descr[df_descr_colnames]
column_format = self.create_column_format_for_tex(df_descr)
df_descr.to_latex(os.path.join(path, "station_describe_short.tex"), na_rep='---', column_format=column_format)
return df
@staticmethod
def create_column_format_for_tex(df: pd.DataFrame) -> str:
Loading