eurocropsml.dataset.splits.split_dataset_by_classΒΆ

split_dataset_by_class(data_dir: Path, split_dir: Path, satellite: list[Literal['S1', 'S2']], year: str, num_samples: dict[str, str | int | list[int | str]], seed: int, pretrain_classes: set[int], finetune_classes: set[int] | None = None, meadow_class: int | None = None, test_size: float = 0.2) NoneΒΆ

Split dataset by 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.

  • 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.

  • pretrain_classes – List with classes used for filtering the data.

  • finetune_classes – List with classes used for filtering the data.

  • 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.