MCPcopy Create free account
hub / github.com/dmlc/xgboost / make_batches

Function make_batches

demo/guide-python/external_memory.py:66–82  ·  view source on GitHub ↗

Write ``n_batches`` synthetic regression batches as `.npy` pairs under ``work_dir``.

(
    n_samples_per_batch: int,
    n_features: int,
    n_batches: int,
    work_dir: str,
)

Source from the content-addressed store, hash-verified

64
65
66def make_batches(
67 n_samples_per_batch: int,
68 n_features: int,
69 n_batches: int,
70 work_dir: str,
71) -> List[Tuple[str, str]]:
72 """Write ``n_batches`` synthetic regression batches as `.npy` pairs under ``work_dir``."""
73 files: List[Tuple[str, str]] = []
74 rng = np.random.RandomState(1994)
75 for i in range(n_batches):
76 X, y = make_regression(n_samples_per_batch, n_features, random_state=rng)
77 X_path = os.path.join(work_dir, "X-" + str(i) + ".npy")
78 y_path = os.path.join(work_dir, "y-" + str(i) + ".npy")
79 np.save(X_path, X)
80 np.save(y_path, y)
81 files.append((X_path, y_path))
82 return files
83
84
85class Iterator(xgboost.DataIter):

Callers 1

mainFunction · 0.70

Calls 1

make_regressionFunction · 0.85

Tested by

no test coverage detected