def generate_samples(self, iteration): # generating 50 samples and taking the mean
     iter_spacegan = get_spacegan_config(iteration, self.prob_config, self.check_config, self.cond_input, self.target)
     
     # training samples
     gan_samples_df = pd.DataFrame(index=range(self.cond_input.shape[0]), columns=self.cond_vars + self.neighbour_list + self.output_vars)
     gan_samples_df[self.cond_vars + self.neighbour_list] = self.cond_input
     gan_samples_df[self.output_vars] = self.target
     for i in range(self.check_config["n_samples"]):
         gan_samples_df["sample_" + str(i)] = iter_spacegan.predict(self.cond_input)
     return gan_samples_df
Example #2
0
# computing metrics
gan_metrics = compute_metrics(target, cond_input, prob_config, check_config,
                              coord_input, neighbours)

# selecting and sampling gan
for criteria in list(check_config["perf_metrics"].keys()):
    # find best config
    criteria_info = check_config["pf_metrics_setting"][criteria]
    perf_metrics = gan_metrics[criteria_info["metric_level"]]
    perf_values = criteria_info["agg_function"](perf_metrics[[criteria]])
    best_config = perf_metrics.index[criteria_info["rank_function"](
        perf_values)]

    # get and set best space gan
    best_spacegan = get_spacegan_config(int(best_config), prob_config,
                                        check_config, cond_input, target)
    # training samples
    gan_samples_df = pd.DataFrame(index=range(cond_input.shape[0]),
                                  columns=cond_vars + neighbour_list +
                                  output_vars)
    gan_samples_df[cond_vars + neighbour_list] = cond_input
    gan_samples_df[output_vars] = target
    for i in range(check_config["n_samples"]):
        gan_samples_df["sample_" + str(i)] = best_spacegan.predict(
            gan_samples_df[cond_vars + neighbour_list])

    # export results
    gan_samples_df.to_pickle(model_save_prefix + "grid_" + criteria +
                             ".pkl.gz")
gan_metrics["agg_metrics"].to_pickle(model_save_prefix +
                                     "grid_checkmetrics.pkl.gz")
Example #3
0
        target, cond_input, spacegan_config.prob_config,
        spacegan_config.check_config, coord_input, spacegan_config.neighbours)

    # selecting and sampling gan
    for criteria in list(spacegan_config.check_config["perf_metrics"].keys()):
        # find best config
        criteria_info = spacegan_config.check_config["pf_metrics_setting"][
            criteria]
        perf_metrics = gan_metrics[criteria_info["metric_level"]]
        perf_values = criteria_info["agg_function"](perf_metrics[[criteria]])
        best_config = perf_metrics.index[criteria_info["rank_function"](
            perf_values)]

        # get and set best space gan
        best_spacegan = spacegan_selection.get_spacegan_config(
            int(best_config), spacegan_config.prob_config,
            spacegan_config.check_config, cond_input, target)
        # training samples
        gan_samples_df = pd.DataFrame(index=range(cond_input.shape[0]),
                                      columns=spacegan_config.cond_vars +
                                      neighbour_list +
                                      spacegan_config.output_vars)
        gan_samples_df[spacegan_config.cond_vars + neighbour_list] = cond_input
        gan_samples_df[spacegan_config.output_vars] = target
        for i in range(spacegan_config.check_config["n_samples"]):
            gan_samples_df["sample_" + str(i)] = best_spacegan.predict(
                gan_samples_df[spacegan_config.cond_vars + neighbour_list])

        # export results
        gan_samples_df.to_pickle("grid_" + criteria + ".pkl.gz")
    spacegan.df_losses.to_pickle("grid_spaceganlosses.pkl.gz")