:return: (X, Xpl)
(
X: List[object],
Xpl: Union[pl.DataFrame, pl.Series],
offset: int,
multiple_chunks: bool
)
| 326 | |
| 327 | |
| 328 | def preprocess_data( |
| 329 | X: List[object], |
| 330 | Xpl: Union[pl.DataFrame, pl.Series], |
| 331 | offset: int, |
| 332 | multiple_chunks: bool |
| 333 | ) -> Tuple[List[object], Union[pl.DataFrame, pl.Series]]: |
| 334 | """ |
| 335 | :return: (X, Xpl) |
| 336 | """ |
| 337 | |
| 338 | if offset: |
| 339 | X = X[offset:] |
| 340 | Xpl = Xpl.slice(offset=offset) |
| 341 | if has_pyarrow: |
| 342 | if isinstance(Xpl, pl.DataFrame): |
| 343 | for column in Xpl: |
| 344 | assert column.to_arrow().offset == offset |
| 345 | elif isinstance(Xpl, pl.Series): |
| 346 | assert Xpl.to_arrow().offset == offset |
| 347 | |
| 348 | n_samples_after_offset = len(X) |
| 349 | |
| 350 | if multiple_chunks: |
| 351 | cut_pos = n_samples_after_offset // 3 |
| 352 | Xpl1 = Xpl.slice(offset=0, length=cut_pos) |
| 353 | Xpl2 = Xpl.slice(offset=cut_pos) |
| 354 | Xpl = pl.concat([Xpl1, Xpl2]) |
| 355 | if isinstance(Xpl, pl.DataFrame): |
| 356 | for column in Xpl: |
| 357 | assert column.n_chunks() == 2 |
| 358 | elif isinstance(Xpl, pl.Series): |
| 359 | assert Xpl.n_chunks() == 2 |
| 360 | |
| 361 | return X, Xpl |
| 362 | |
| 363 | |
| 364 | def generate_group_sizes(n_samples: int, min_group_size: int, max_group_size: int, seed: int = 42) -> List[int]: |
no test coverage detected