2023-10-23 03:14:35 +02:00
|
|
|
import yaml
|
2023-10-20 23:36:05 +02:00
|
|
|
|
|
|
|
defalut_env = {
|
|
|
|
"DATASET_NAME": "rcv1",
|
|
|
|
"DATASET_TARGET": "CCAT",
|
2023-10-23 03:14:35 +02:00
|
|
|
"METRICS": ["acc", "f1"],
|
2023-10-20 23:36:05 +02:00
|
|
|
"COMP_ESTIMATORS": [
|
2023-10-23 03:14:35 +02:00
|
|
|
"our_bin_SLD",
|
|
|
|
"our_bin_SLD_nbvs",
|
|
|
|
"our_bin_SLD_bcts",
|
|
|
|
"our_bin_SLD_ts",
|
|
|
|
"our_bin_SLD_vs",
|
|
|
|
"our_bin_CC",
|
|
|
|
"our_mul_SLD",
|
|
|
|
"our_mul_SLD_nbvs",
|
|
|
|
"our_mul_SLD_bcts",
|
|
|
|
"our_mul_SLD_ts",
|
|
|
|
"our_mul_SLD_vs",
|
|
|
|
"our_mul_CC",
|
|
|
|
"ref",
|
|
|
|
"kfcv",
|
|
|
|
"atc_mc",
|
|
|
|
"atc_ne",
|
|
|
|
"doc_feat",
|
|
|
|
"rca",
|
|
|
|
"rca_star",
|
2023-10-20 23:36:05 +02:00
|
|
|
],
|
|
|
|
"DATASET_N_PREVS": 9,
|
2023-10-23 03:14:35 +02:00
|
|
|
"OUT_DIR_NAME": "output",
|
|
|
|
"PLOT_DIR_NAME": "plot",
|
2023-10-20 23:36:05 +02:00
|
|
|
"PROTOCOL_N_PREVS": 21,
|
|
|
|
"PROTOCOL_REPEATS": 100,
|
|
|
|
"SAMPLE_SIZE": 1000,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Environ:
|
|
|
|
def __init__(self, **kwargs):
|
2023-10-23 03:14:35 +02:00
|
|
|
self.exec = []
|
|
|
|
self.confs = {}
|
|
|
|
self.__setdict(kwargs)
|
|
|
|
|
|
|
|
def __setdict(self, d):
|
|
|
|
for k, v in d.items():
|
2023-10-20 23:36:05 +02:00
|
|
|
self.__setattr__(k, v)
|
|
|
|
|
2023-10-23 03:14:35 +02:00
|
|
|
def load_conf(self):
|
|
|
|
with open("conf.yaml", "r") as f:
|
|
|
|
confs = yaml.safe_load(f)
|
|
|
|
|
|
|
|
for common in confs["commons"]:
|
|
|
|
name = common["DATASET_NAME"]
|
|
|
|
if "DATASET_TARGET" in common:
|
|
|
|
name += "_" + common["DATASET_TARGET"]
|
|
|
|
for k, d in confs["confs"].items():
|
|
|
|
_k = f"{name}_{k}"
|
|
|
|
self.confs[_k] = common | d
|
|
|
|
self.exec.append(_k)
|
|
|
|
|
|
|
|
if "exec" in confs:
|
|
|
|
if len(confs["exec"]) > 0:
|
|
|
|
self.exec = confs["exec"]
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
self.load_conf()
|
|
|
|
for _conf in self.exec:
|
|
|
|
if _conf in self.confs:
|
|
|
|
self.__setdict(self.confs[_conf])
|
|
|
|
yield _conf
|
|
|
|
|
2023-10-20 23:36:05 +02:00
|
|
|
|
|
|
|
env = Environ(**defalut_env)
|