implementing the 'total' function of IFCB protocols
This commit is contained in:
parent
f18bce5f80
commit
8a6579428b
|
@ -6,14 +6,18 @@ from quapy.evaluation import evaluation_report
|
||||||
def newLR():
|
def newLR():
|
||||||
return LogisticRegression(n_jobs=-1)
|
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)
|
print("Experiment with "+quant_name)
|
||||||
|
|
||||||
train, test_gen = qp.datasets.fetch_IFCB()
|
train, test_gen = qp.datasets.fetch_IFCB()
|
||||||
|
|
|
@ -20,6 +20,15 @@ class IFCBTrainSamplesFromDir(AbstractProtocol):
|
||||||
y = s.iloc[:, 0].to_numpy()
|
y = s.iloc[:, 0].to_numpy()
|
||||||
yield X, y
|
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):
|
class IFCBTestSamples(AbstractProtocol):
|
||||||
|
|
||||||
def __init__(self, path_dir:str, test_prevalences_path: str):
|
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()
|
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)
|
prevalences = test_sample.iloc[1:].to_numpy().astype(float)
|
||||||
yield X, prevalences
|
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)
|
Loading…
Reference in New Issue