eurocropsml.dataset.splits.split_dataset_by_regionΒΆ
- split_dataset_by_region(data_dir: Path, split_dir: Path, split: Literal['region', 'regionclass'], satellite: list[Literal['S1', 'S2']], year: str, num_samples: dict[str, str | int | list[int | str]], seed: int, benchmark: bool, zenodo_base_url: str, pretrain_classes: set[int], pretrain_regions: set[str], finetune_classes: set[int] | None = None, finetune_regions: set[str] | None = None, meadow_class: int | None = None, test_size: float = 0.2) NoneΒΆ
Split dataset by regions or regions and classes.
- Parameters:
data_dir β Path that contains .npy files where labels and data are stored.
split_dir β Directory where splits are going to be saved to.
split β Kind of data split to apply.
satellite β Whether to build the splits using Sentinel-1 or Sentinel-2 or both.
year β Year for which data are to be processed.
num_samples β Number of samples to sample for finetuning.
seed β Random seed for data split.
benchmark β Flag in order to build the same split as used in the EuroCropsML dataset (https://arxiv.org/abs/2407.17458). The split was created when only Sentinel-2 data was available. If benchmark is set to True, the split will be loaded from Zenodo version 9. If βS1β in satellite and the EuroCropsSplit.base_name matches one of the Zenodo splits, then for pre-training the remaining Sentinel-1 parcels (which are not in the S2 data) are distributed between train and validation. For fine-tuning, there are only 149 parcels in S1 which are not in S2. We therefore ignore them completely, s.t. the fine-tuning split remains exactly the same. If the benchmark is set to False, a new deterministic train-val(-test) split is created based on all parcels present in the data. If split!=βregionβ, benchmark is set to False.
zenodo_base_url β Base url for downloading benchmark region-split from Zenodo (version 9).
pretrain_classes β Classes of the requested dataset split for hyperparameter tuning and pretraining.
finetune_classes β Classes of the requested dataset split for finetuning.
pretrain_regions β Regions of the requested dataset split for hyperparameter tuning and pretraining.
finetune_regions β Regions of the requested dataset split for finetuning. None if EuroCrops should only be used for pretraining.
meadow_class β Meadow class identifier. If specified, for the pre-training split, the meadow class will be downsampled to the median frequency of all other classes If None, no downsampling is taking place.
test_size β Amount of data used for validation (test set). Defaults to 0.2.
- Raises:
Exception β If there are similar samples within pretrain and finetune data-split.