zamba.data.metadata¶
Functions¶
create_site_specific_splits(site: pd.Series, proportions: Dict[str, int], random_state: Optional[Union[int, np.random.mtrand.RandomState]] = 989)
¶
Splits sites into distinct groups whose sizes roughly matching the given proportions. Null sites are randomly assigned to groups using the provided proportions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
site |
pd.Series
|
A series of sites, one element per observation, |
required |
proportions |
dict
|
A dict whose keys are the resulting groups and whose values are the rough proportion of data in each group. |
required |
seed |
int
|
Seed for random split of null sites. |
required |
Example
Split data into groups where each site is in one and only one group with roughly 50-25-25 train-val-holdout proportions.
create_site_specific_splits(site, proportions={"train": 2, "val": 1, "holdout": 1})
Returns:
Type | Description |
---|---|
pd.Series: A series containing the resulting split, one element per observation. |
Source code in zamba/data/metadata.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
one_hot_to_labels(one_hot: pd.DataFrame, column_prefix: Optional[str] = 'species_') -> pd.DataFrame
¶
Source code in zamba/data/metadata.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
roundrobin(*iterables)
¶
roundrobin('ABC', 'D', 'EF') --> A D E B F C
Source code in zamba/data/metadata.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|