gitlabds 2.4.2__tar.gz → 2.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitlabds-2.4.2 → gitlabds-2.4.3}/PKG-INFO +1 -1
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/split_data.py +0 -3
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds.egg-info/PKG-INFO +1 -1
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds.egg-info/SOURCES.txt +2 -1
- gitlabds-2.4.3/tests/test_split_data.py +59 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/LICENSE +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/README.md +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/__init__.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/baselines.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/config_generator.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/dummy.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/feature_descriptions.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/feature_reduction.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/insights.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/memory_optimization.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/missing.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/model_evaluator.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/monitoring_metrics.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/outliers.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/record_benchmarking.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/serving_features.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/snowflake_connectors.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds/trends.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds.egg-info/dependency_links.txt +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds.egg-info/requires.txt +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/gitlabds.egg-info/top_level.txt +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/pyproject.toml +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/setup.cfg +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/setup.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/tests/test_feature_reduction.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/tests/test_record_benchmarking.py +0 -0
- {gitlabds-2.4.2 → gitlabds-2.4.3}/tests/test_snowflake_connectors.py +0 -0
|
@@ -140,7 +140,6 @@ def split_data(
|
|
|
140
140
|
train_df, test_df = train_test_split(
|
|
141
141
|
df_copy,
|
|
142
142
|
train_size=train_pct,
|
|
143
|
-
test_size=1-train_pct,
|
|
144
143
|
random_state=random_state,
|
|
145
144
|
shuffle=shuffle,
|
|
146
145
|
stratify=stratify_param
|
|
@@ -241,7 +240,6 @@ def split_data(
|
|
|
241
240
|
train_groups, test_groups = train_test_split(
|
|
242
241
|
group_target.index.values,
|
|
243
242
|
train_size=train_pct,
|
|
244
|
-
test_size=1 - train_pct,
|
|
245
243
|
random_state=random_state,
|
|
246
244
|
shuffle=shuffle,
|
|
247
245
|
stratify=group_stratify,
|
|
@@ -263,7 +261,6 @@ def split_data(
|
|
|
263
261
|
X_train, X_test, y_train, y_test = train_test_split(
|
|
264
262
|
X, y,
|
|
265
263
|
train_size=train_pct,
|
|
266
|
-
test_size=1-train_pct,
|
|
267
264
|
random_state=random_state,
|
|
268
265
|
shuffle=shuffle,
|
|
269
266
|
stratify=stratify_param
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from gitlabds import split_data
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _frame(n: int, groups: int = 0) -> pd.DataFrame:
|
|
9
|
+
rng = np.random.default_rng(0)
|
|
10
|
+
data = {
|
|
11
|
+
"x1": rng.random(n),
|
|
12
|
+
"x2": rng.random(n),
|
|
13
|
+
"y": (np.arange(n) % 2).astype(int),
|
|
14
|
+
}
|
|
15
|
+
if groups:
|
|
16
|
+
data["grp"] = np.repeat(np.arange(groups), n // groups)
|
|
17
|
+
return pd.DataFrame(data)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.mark.parametrize("train_pct", [0.7, 0.85])
|
|
21
|
+
@pytest.mark.parametrize("n", [100, 1000])
|
|
22
|
+
def test_no_dv_split_on_exact_multiples(n, train_pct):
|
|
23
|
+
"""Row counts where (1 - train_pct) * n is a whole number must not raise."""
|
|
24
|
+
df = _frame(n)
|
|
25
|
+
train_df, y_train, test_df, y_test, _ = split_data(
|
|
26
|
+
df, train_pct=train_pct, stratify=False
|
|
27
|
+
)
|
|
28
|
+
assert len(train_df) + len(test_df) == n
|
|
29
|
+
assert y_train.empty and y_test.empty
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.parametrize("train_pct", [0.7, 0.85])
|
|
33
|
+
@pytest.mark.parametrize("n", [100, 1000])
|
|
34
|
+
def test_row_level_split_on_exact_multiples(n, train_pct):
|
|
35
|
+
df = _frame(n)
|
|
36
|
+
X_train, y_train, X_test, y_test, _ = split_data(
|
|
37
|
+
df, dv="y", train_pct=train_pct, stratify=False
|
|
38
|
+
)
|
|
39
|
+
assert len(X_train) + len(X_test) == n
|
|
40
|
+
assert len(y_train) == len(X_train)
|
|
41
|
+
assert len(y_test) == len(X_test)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.mark.parametrize("train_pct", [0.7, 0.85])
|
|
45
|
+
def test_group_split_on_exact_multiple_group_count(train_pct):
|
|
46
|
+
"""The group count, not the row count, drives the group-aware split size."""
|
|
47
|
+
n, groups = 2000, 100
|
|
48
|
+
df = _frame(n, groups=groups)
|
|
49
|
+
X_train, y_train, X_test, y_test, _ = split_data(
|
|
50
|
+
df,
|
|
51
|
+
dv="y",
|
|
52
|
+
groupby="grp",
|
|
53
|
+
train_pct=train_pct,
|
|
54
|
+
stratify=False,
|
|
55
|
+
)
|
|
56
|
+
assert len(X_train) + len(X_test) == n
|
|
57
|
+
train_groups = set(X_train["grp"])
|
|
58
|
+
test_groups = set(X_test["grp"])
|
|
59
|
+
assert not (train_groups & test_groups)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|