1
0
Fork 0

implementing the 'total' function of IFCB protocols

This commit is contained in:
Alejandro Moreo Fernandez 2023-11-08 11:31:33 +01:00
parent f18bce5f80
commit 8a6579428b
2 changed files with 29 additions and 8 deletions

View File

@ -6,14 +6,18 @@ from quapy.evaluation import evaluation_report
def newLR():
return LogisticRegression(n_jobs=-1)
quantifiers = {'CC':qp.method.aggregative.CC(newLR()),
'ACC':qp.method.aggregative.ACC(newLR()),
'PCC':qp.method.aggregative.PCC(newLR()),
'PACC':qp.method.aggregative.PACC(newLR()),
'HDy':qp.method.aggregative.DistributionMatching(newLR()),
'EMQ':qp.method.aggregative.EMQ(newLR())}
for quant_name, quantifier in quantifiers.items():
quantifiers = [
('CC', qp.method.aggregative.CC(newLR())),
('ACC', qp.method.aggregative.ACC(newLR())),
('PCC', qp.method.aggregative.PCC(newLR())),
('PACC', qp.method.aggregative.PACC(newLR())),
('HDy', qp.method.aggregative.DistributionMatching(newLR())),
('EMQ', qp.method.aggregative.EMQ(newLR()))
]
for quant_name, quantifier in quantifiers:
print("Experiment with "+quant_name)
train, test_gen = qp.datasets.fetch_IFCB()

View File

@ -20,6 +20,15 @@ class IFCBTrainSamplesFromDir(AbstractProtocol):
y = s.iloc[:, 0].to_numpy()
yield X, y
def total(self):
"""
Returns the total number of samples that the protocol generates.
:return: The number of training samples to generate.
"""
return len(self.samples)
class IFCBTestSamples(AbstractProtocol):
def __init__(self, path_dir:str, test_prevalences_path: str):
@ -32,3 +41,11 @@ class IFCBTestSamples(AbstractProtocol):
X = pd.read_csv(os.path.join(self.path_dir,test_sample['sample']+'.csv')).to_numpy()
prevalences = test_sample.iloc[1:].to_numpy().astype(float)
yield X, prevalences
def total(self):
"""
Returns the total number of samples that the protocol generates.
:return: The number of test samples to generate.
"""
return len(self.test_prevalences.index)