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,
)
| 64 | |
| 65 | |
| 66 | def 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 | |
| 85 | class Iterator(xgboost.DataIter): |
no test coverage detected