Example #1
0
        "regression_" + name, case_name
    )

    n_samples_list = regression_history_all[0][0].keys()
    error_samples = sorted(n_samples_list)
    error_avgs = np.zeros(len(n_samples_list))
    error_min = np.zeros(len(n_samples_list))
    error_max = np.zeros(len(n_samples_list))
    error_repetitions = np.zeros(len(n_samples_list))
    for i, n_samples in enumerate(error_samples):
        error_list = []
        for regression_history, features_range in regression_history_all:
            error = calculate_error(
                X_true,
                y_true,
                regression_history[n_samples],
                features_range,
                error_measure=mean_relative_error,
            )
            error_list.append(error)
        error_avgs[i] = np.average(error_list)
        error_min[i], error_max[i] = sp.stats.t.interval(
            0.95,
            len(error_list) - 1,
            loc=np.mean(error_list),
            scale=sp.stats.sem(error_list),
        )
        error_repetitions[i] = len(error_list)

    plt.plot(error_samples, error_avgs * 100, label="\\small " + label)
    plt.fill_between(error_samples, error_min * 100, error_max * 100, alpha=0.5)
from active_learning_cfd.error_measures import calculate_error

reference_filename = "reference_solution.csv"

reference_solution = np.genfromtxt(reference_filename, delimiter=",")
X_true = reference_solution[:, 0:-1]
y_true = reference_solution[:, -1]

strategy_list = (
    "gp_rbf_std",
    "gp_52_std",
    "lin_greedyio",
    "rfr_greedyio",
    "svr_greedyio",
    "nn_greedyio",
)

plt.figure()
for name in strategy_list:
    regression_history = load_regression_history("regression_" + name,
                                                 "algebraic")

    error_list = np.array(
        [[n_samples, calculate_error(X_true, y_true, regressor)]
         for n_samples, regressor in regression_history])

    plt.plot(error_list[:, 0], error_list[:, 1], label=name)

plt.legend()
plt.show()