From b36fda5f108e462b81d6d44b7da176b1806c5da4 Mon Sep 17 00:00:00 2001 From: Alejandro Moreo Date: Tue, 24 Oct 2023 11:54:19 +0200 Subject: [PATCH] adding plankton --- quapy/data/datasets.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/quapy/data/datasets.py b/quapy/data/datasets.py index 5a0dde1..fb17730 100644 --- a/quapy/data/datasets.py +++ b/quapy/data/datasets.py @@ -624,3 +624,26 @@ def fetch_lequa2022(task, data_home=None): return train, val_gen, test_gen +def fetch_IFCB(data_home=None): + + if data_home is None: + data_home = get_quapy_home() + + URL_TRAINDEV=f'https://zenodo.org/records/10036244/files/IFCB.train.zip' + URL_TEST=f'https://zenodo.org/records/10036244/files/IFCB.test.zip' + URL_TEST_PREV=f'https://zenodo.org/records/10036244/files/IFCB.test_prevalences.zip' + + ifcb_dir = join(data_home, 'ifcb') + os.makedirs(ifcb_dir, exist_ok=True) + + def download_unzip_and_remove(unzipped_path, url): + tmp_path = join(ifcb_dir, 'tmp.zip') + download_file_if_not_exists(url, tmp_path) + with zipfile.ZipFile(tmp_path) as file: + file.extractall(unzipped_path) + os.remove(tmp_path) + + if not os.path.exists(join(ifcb_dir, task)): + download_unzip_and_remove(ifcb_dir, URL_TRAINDEV) + download_unzip_and_remove(ifcb_dir, URL_TEST) + download_unzip_and_remove(ifcb_dir, URL_TEST_PREV) \ No newline at end of file