added aggregative bootstrap

This commit is contained in:
Alejandro Moreo Fernandez 2025-11-18 10:12:41 +01:00
parent be465712cd
commit 277a2e617f
1 changed files with 7 additions and 6 deletions

View File

@ -9,7 +9,7 @@ from sklearn.model_selection import GridSearchCV, StratifiedKFold
from copy import deepcopy as cp
import quapy as qp
from BayesianKDEy._bayeisan_kdey import BayesianKDEy
from method.aggregative import DistributionMatchingY as DMy
from quapy.method.aggregative import DistributionMatchingY as DMy
from quapy.method.base import BinaryQuantifier
from quapy.model_selection import GridSearchQ
from quapy.data import Dataset
@ -50,12 +50,13 @@ def methods():
acc_hyper = {}
hdy_hyper = {'n_bins': [3,4,5,8,16,32]}
kdey_hyper = {'bandwidth': [0.001, 0.005, 0.01, 0.05, 0.1, 0.2]}
yield 'BootstrapACC', AggregativeBootstrap(ACC(LR()), n_test_samples=1000, random_state=0), acc_hyper
# yield 'BootstrapHDy', AggregativeBootstrap(DMy(LR(), divergence='HD'), n_test_samples=1000, random_state=0), hdy_hyper
# yield 'BootstrapKDEy', AggregativeBootstrap(KDEyML(LR()), n_test_samples=1000, random_state=0), kdey_hyper
wrap_hyper = lambda dic: {f'quantifier__{k}':v for k,v in dic.items()}
# yield 'BootstrapACC', AggregativeBootstrap(ACC(LR()), n_test_samples=1000, random_state=0), wrap_hyper(acc_hyper)
yield 'BootstrapHDy', AggregativeBootstrap(DMy(LR(), divergence='HD'), n_test_samples=1000, random_state=0), wrap_hyper(hdy_hyper)
#yield 'BootstrapKDEy', AggregativeBootstrap(KDEyML(LR()), n_test_samples=1000, random_state=0), wrap_hyper(kdey_hyper)
# yield 'BayesianACC', BayesianCC(LR(), mcmc_seed=0), acc_hyper
# yield 'BayesianHDy', PQ(LR(), stan_seed=0), hdy_hyper
yield 'BayesianKDEy', BayesianKDEy(LR(), mcmc_seed=0), kdey_hyper
# yield 'BayesianKDEy', BayesianKDEy(LR(), mcmc_seed=0), kdey_hyper
def experiment(dataset: Dataset, method: WithConfidenceABC, grid: dict):
@ -99,7 +100,7 @@ def experiment(dataset: Dataset, method: WithConfidenceABC, grid: dict):
results['coverage'].append(region.coverage(true_prevalence))
results['amplitude'].append(region.montecarlo_proportion(n_trials=50_000))
results['test-time'].append(ttime)
results['samples'].append(optim_quantifier.)
results['samples'].append(region.samples)
report = {
'optim_hyper': best_params,