tsdive.eval.GroupSplit
dataclass
¶
GroupSplit(
group_col: str,
stratum_col: str,
n_folds: int,
seed: int,
fold_of_group: dict[str, int],
folds: tuple[tuple[str, ...], ...],
fold_sizes: tuple[int, ...],
strata_counts: tuple[dict[str, int], ...],
group_sizes: dict[str, int],
)
A k-fold split in which every group sits entirely inside one fold.
Methods:
| Name | Description |
|---|---|
groups |
The group keys held out in |
test_indices |
Row positions of |
train_indices |
Row positions of |
strata_present |
The strata with at least one item in |
leakage_check |
Refuse a split where any group reached more than one fold. |
Attributes:
| Name | Type | Description |
|---|---|---|
group_col |
str
|
|
stratum_col |
str
|
|
n_folds |
int
|
|
seed |
int
|
|
fold_of_group |
dict[str, int]
|
|
folds |
tuple[tuple[str, ...], ...]
|
|
fold_sizes |
tuple[int, ...]
|
|
strata_counts |
tuple[dict[str, int], ...]
|
|
group_sizes |
dict[str, int]
|
|
test_indices
¶
test_indices(items: DataFrame, fold: int) -> list[int]
Row positions of items whose group is held out in fold.
train_indices
¶
train_indices(items: DataFrame, fold: int) -> list[int]
Row positions of items whose group is not held out in fold.
leakage_check
¶
leakage_check() -> None
Refuse a split where any group reached more than one fold.
Also refuses a fold list that disagrees with fold_of_group or
that omits a known group: a split whose bookkeeping is wrong is
not a split whose numbers may be published.