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

Function make_batches

demo/guide-python/distributed_extmem_basic.py:57–70  ·  view source on GitHub ↗

Create multiple batches of synthetic data and return their file paths.

(
    n_samples_per_batch: int, n_features: int, n_batches: int, tmpdir: str, rank: int
)

Source from the content-addressed store, hash-verified

55
56
57def make_batches(
58 n_samples_per_batch: int, n_features: int, n_batches: int, tmpdir: str, rank: int
59) -> List[Tuple[str, str]]:
60 """Create multiple batches of synthetic data and return their file paths."""
61 files: List[Tuple[str, str]] = []
62 rng = np.random.RandomState(rank)
63 for i in range(n_batches):
64 X, y = make_regression(n_samples_per_batch, n_features, random_state=rng)
65 X_path = os.path.join(tmpdir, f"X-r{rank}-{i}.npy")
66 y_path = os.path.join(tmpdir, f"y-r{rank}-{i}.npy")
67 np.save(X_path, X)
68 np.save(y_path, y)
69 files.append((X_path, y_path))
70 return files
71
72
73class Iterator(xgboost.DataIter):

Callers 1

hist_trainFunction · 0.70

Calls 1

make_regressionFunction · 0.85

Tested by

no test coverage detected