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
)
| 55 | |
| 56 | |
| 57 | def 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 | |
| 73 | class Iterator(xgboost.DataIter): |
no test coverage detected