From 59ef17c86cf28d0f469700fbb594c5d39f8ddb2d Mon Sep 17 00:00:00 2001 From: Alejandro Moreo Date: Thu, 4 Dec 2025 20:10:25 +0100 Subject: [PATCH] ilr only on multiclass --- BayesianKDEy/_bayeisan_kdey.py | 2 +- BayesianKDEy/full_experiments.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/BayesianKDEy/_bayeisan_kdey.py b/BayesianKDEy/_bayeisan_kdey.py index 8f77fb1..89f63ad 100644 --- a/BayesianKDEy/_bayeisan_kdey.py +++ b/BayesianKDEy/_bayeisan_kdey.py @@ -128,7 +128,7 @@ class BayesianKDEy(AggregativeSoftQuantifier, KDEBase, WithConfidenceABC): elif self.explore=='ilr': ilr = ILRtransformation() ilr_point = ilr(prev) - dir_noise = rng.normal(scale=step_size, size=d) + dir_noise = rng.normal(scale=step_size, size=d-1) ilr_neighbour = ilr_point + dir_noise neighbour = ilr.inverse(ilr_neighbour) assert in_simplex(neighbour), 'wrong ILR transformation' diff --git a/BayesianKDEy/full_experiments.py b/BayesianKDEy/full_experiments.py index d821cb5..20958fd 100644 --- a/BayesianKDEy/full_experiments.py +++ b/BayesianKDEy/full_experiments.py @@ -49,8 +49,10 @@ def methods(): hdy_hyper = {'nbins': [3,4,5,8,16,32]} kdey_hyper = {'bandwidth': [0.001, 0.005, 0.01, 0.05, 0.1, 0.2]} kdey_hyper_clr = {'bandwidth': [0.05, 0.1, 0.5, 1., 2., 5.]} - only_binary = True - multiclass_method = False + + multiclass_method = 'multiclass' + only_binary = 'only_binary' + only_multiclass = 'only_multiclass' yield 'BootstrapACC', ACC(LR()), acc_hyper, lambda hyper: AggregativeBootstrap(ACC(LR()), n_test_samples=1000, random_state=0), multiclass_method yield 'BayesianACC', ACC(LR()), acc_hyper, lambda hyper: BayesianCC(LR(), mcmc_seed=0), multiclass_method @@ -63,7 +65,7 @@ def methods(): yield 'BayesianKDEy*', KDEyCLR(LR()), kdey_hyper_clr, lambda hyper: BayesianKDEy(kernel='aitchison', mcmc_seed=0, **hyper), multiclass_method yield 'BayKDEy*CLR', KDEyCLR(LR()), kdey_hyper_clr, lambda hyper: BayesianKDEy(kernel='aitchison', mcmc_seed=0, explore='clr', step_size=.15, **hyper), multiclass_method # yield 'BayKDEy*CLR2', KDEyCLR(LR()), kdey_hyper_clr, lambda hyper: BayesianKDEy(kernel='aitchison', mcmc_seed=0, explore='clr', step_size=.05, **hyper), multiclass_method - yield 'BayKDEy*ILR', KDEyCLR(LR()), kdey_hyper_clr, lambda hyper: BayesianKDEy(kernel='aitchison', mcmc_seed=0, explore='ilr', step_size=.15, **hyper), multiclass_method + yield 'BayKDEy*ILR', KDEyCLR(LR()), kdey_hyper_clr, lambda hyper: BayesianKDEy(kernel='aitchison', mcmc_seed=0, explore='ilr', step_size=.15, **hyper), only_multiclass def model_selection(train: LabelledCollection, point_quantifier: AggregativeQuantifier, grid: dict): @@ -161,8 +163,10 @@ if __name__ == '__main__': is_binary = data.n_classes==2 result_subdir = result_dir / ('binary' if is_binary else 'multiclass') hyper_subdir = result_dir / 'hyperparams' / ('binary' if is_binary else 'multiclass') - for method_name, method, hyper_params, withconf_constructor, only_binary in methods(): - if only_binary and not is_binary: + for method_name, method, hyper_params, withconf_constructor, method_scope in methods(): + if method_scope == 'only_binary' and not is_binary: + continue + if method_scope == 'only_multiclass' and is_binary: continue result_path = experiment_path(result_subdir, data_name, method_name) hyper_path = experiment_path(hyper_subdir, data_name, method.__class__.__name__)