From dc2fa05cf8fc37cd9ad43d857af73523af018a35 Mon Sep 17 00:00:00 2001 From: Alex Moreo Date: Sun, 29 Aug 2021 11:03:51 +0200 Subject: [PATCH] launching experiments --- MultiLabel/main.py | 32 +++++++++++++++++--------------- MultiLabel/mldata.py | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/MultiLabel/main.py b/MultiLabel/main.py index afb03e7..ed3f14d 100644 --- a/MultiLabel/main.py +++ b/MultiLabel/main.py @@ -38,28 +38,28 @@ n_samples = 5000 def models(): yield 'NaiveCC', MultilabelNaiveAggregativeQuantifier(CC(cls())) - # yield 'NaivePCC', MultilabelNaiveAggregativeQuantifier(PCC(cls())) - # yield 'NaiveACC', MultilabelNaiveAggregativeQuantifier(ACC(cls())) - # yield 'NaivePACC', MultilabelNaiveAggregativeQuantifier(PACC(cls())) + yield 'NaivePCC', MultilabelNaiveAggregativeQuantifier(PCC(cls())) + yield 'NaiveACC', MultilabelNaiveAggregativeQuantifier(ACC(cls())) + yield 'NaivePACC', MultilabelNaiveAggregativeQuantifier(PACC(cls())) # yield 'NaiveHDy', MultilabelNaiveAggregativeQuantifier(HDy(cls())) # yield 'NaiveSLD', MultilabelNaiveAggregativeQuantifier(EMQ(calibratedCls())) - # yield 'StackCC', MLCC(MultilabelStackedClassifier(cls())) - # yield 'StackPCC', MLPCC(MultilabelStackedClassifier(cls())) - # yield 'StackACC', MLACC(MultilabelStackedClassifier(cls())) - # yield 'StackPACC', MLPACC(MultilabelStackedClassifier(cls())) + yield 'StackCC', MLCC(MultilabelStackedClassifier(cls())) + yield 'StackPCC', MLPCC(MultilabelStackedClassifier(cls())) + yield 'StackACC', MLACC(MultilabelStackedClassifier(cls())) + yield 'StackPACC', MLPACC(MultilabelStackedClassifier(cls())) # yield 'ChainCC', MLCC(ClassifierChain(cls(), cv=None, order='random')) # yield 'ChainPCC', MLPCC(ClassifierChain(cls(), cv=None, order='random')) # yield 'ChainACC', MLACC(ClassifierChain(cls(), cv=None, order='random')) # yield 'ChainPACC', MLPACC(ClassifierChain(cls(), cv=None, order='random')) common={'sample_size':sample_size, 'n_samples': n_samples, 'norm': True, 'means':False, 'stds':False, 'regression':'svr'} - # yield 'MRQ-CC', MLRegressionQuantification(MultilabelNaiveQuantifier(CC(cls())), **common) - # yield 'MRQ-PCC', MLRegressionQuantification(MultilabelNaiveQuantifier(PCC(cls())), **common) - # yield 'MRQ-ACC', MLRegressionQuantification(MultilabelNaiveQuantifier(ACC(cls())), **common) - # yield 'MRQ-PACC', MLRegressionQuantification(MultilabelNaiveQuantifier(PACC(cls())), **common) - # yield 'MRQ-StackCC', MLRegressionQuantification(MLCC(MultilabelStackedClassifier(cls())), **common) - # yield 'MRQ-StackPCC', MLRegressionQuantification(MLPCC(MultilabelStackedClassifier(cls())), **common) - # yield 'MRQ-StackACC', MLRegressionQuantification(MLACC(MultilabelStackedClassifier(cls())), **common) - # yield 'MRQ-StackPACC', MLRegressionQuantification(MLPACC(MultilabelStackedClassifier(cls())), **common) + yield 'MRQ-CC', MLRegressionQuantification(MultilabelNaiveQuantifier(CC(cls())), **common) + yield 'MRQ-PCC', MLRegressionQuantification(MultilabelNaiveQuantifier(PCC(cls())), **common) + yield 'MRQ-ACC', MLRegressionQuantification(MultilabelNaiveQuantifier(ACC(cls())), **common) + yield 'MRQ-PACC', MLRegressionQuantification(MultilabelNaiveQuantifier(PACC(cls())), **common) + yield 'MRQ-StackCC', MLRegressionQuantification(MLCC(MultilabelStackedClassifier(cls())), **common) + yield 'MRQ-StackPCC', MLRegressionQuantification(MLPCC(MultilabelStackedClassifier(cls())), **common) + yield 'MRQ-StackACC', MLRegressionQuantification(MLACC(MultilabelStackedClassifier(cls())), **common) + yield 'MRQ-StackPACC', MLRegressionQuantification(MLPACC(MultilabelStackedClassifier(cls())), **common) # yield 'MRQ-StackCC-app', MLRegressionQuantification(MLCC(MultilabelStackedClassifier(cls())), protocol='app', **common) # yield 'MRQ-StackPCC-app', MLRegressionQuantification(MLPCC(MultilabelStackedClassifier(cls())), protocol='app', **common) # yield 'MRQ-StackACC-app', MLRegressionQuantification(MLACC(MultilabelStackedClassifier(cls())), protocol='app', **common) @@ -176,6 +176,8 @@ def run_experiment(dataset_name, model_name, model): print(f'runing experiment {dataset_name} x {model_name}') train, test = get_dataset(dataset_name) + if train.n_classes>100: + return print_info(train, test) diff --git a/MultiLabel/mldata.py b/MultiLabel/mldata.py index a87dfcd..284144f 100644 --- a/MultiLabel/mldata.py +++ b/MultiLabel/mldata.py @@ -64,7 +64,7 @@ class MultilabelledCollection: return MultilabelledCollection(documents, labels) def train_test_split(self, train_prop=0.6, random_state=None): - raise ValueError('use the scikit-multilearn implementation') + #raise ValueError('use the scikit-multilearn implementation') tr_docs, te_docs, tr_labels, te_labels = \ train_test_split(self.instances, self.labels, train_size=train_prop, random_state=random_state) return MultilabelledCollection(tr_docs, tr_labels), MultilabelledCollection(te_docs, te_labels)