From faba2494b2d2d60a30b3009e55278f4d2bd6328c Mon Sep 17 00:00:00 2001 From: Alejandro Moreo Date: Mon, 16 Sep 2024 17:50:34 +0200 Subject: [PATCH] some plots --- KDEy/experiments.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/KDEy/experiments.py b/KDEy/experiments.py index fb279fc..44f6f00 100644 --- a/KDEy/experiments.py +++ b/KDEy/experiments.py @@ -1,3 +1,5 @@ +import os + import numpy as np from sklearn.linear_model import LogisticRegression from os.path import join @@ -5,7 +7,7 @@ import quapy as qp from quapy.protocol import UPP from quapy.method.aggregative import KDEyML -DEBUG = True +DEBUG = False qp.environ["SAMPLE_SIZE"] = 100 if DEBUG else 500 val_repeats = 100 if DEBUG else 500 @@ -21,7 +23,7 @@ if DEBUG: bandwidth_range = np.linspace(0.01, 0.20, 10) def datasets(): - for dataset_name in qp.datasets.UCI_MULTICLASS_DATASETS[:4]: + for dataset_name in qp.datasets.UCI_MULTICLASS_DATASETS: dataset = qp.datasets.fetch_UCIMulticlassDataset(dataset_name) if DEBUG: dataset = dataset.reduce(random_state=0) @@ -40,7 +42,8 @@ def experiment_dataset(dataset): param_grid={'bandwidth': bandwidth_range}, protocol=UPP(train_va, repeats=val_repeats), refit=False, - n_jobs=-1 + n_jobs=-1, + verbose=True ).fit(train_tr) chosen_bandwidth = modsel.best_params_['bandwidth'] modsel_choice = float(chosen_bandwidth) @@ -83,7 +86,10 @@ def plot_bandwidth(val_choice, test_results): # Mostrar la gráfica plt.grid(True) - plt.show() + # plt.show() + os.makedirs('./plots', exist_ok=True) + plt.savefig(f'./plots/{dataset_name}.png') + for dataset in datasets():