API: preprocessing.resampling
skyulf.preprocessing.resampling
Resampling nodes (Oversampling, Undersampling).
Both Appliers route through :func:apply_dual_engine. Imblearn is purely
pandas/numpy-bound, so the Polars path round-trips through pandas (convert in,
run sampler, convert back) while keeping all engine handling out of class
bodies. Sampler construction is split per-method and per-family so each helper
stays at low CCN.
OversamplingApplier
Bases: BaseApplier
Grow the minority classes with the imblearn over-sampler named in the artifact.
Sees the training split only: :mod:.pipeline excludes the resampling nodes
from apply_on_test/apply_on_validation, so synthetic rows can never
reach a held-out split and inflate its metrics.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
apply(X, y, params)
Resample (X, y) with the configured over-sampler.
y is lifted out of X via target_column when not supplied
separately; with no usable target the data passes through untouched, as
it does for a method no builder recognizes.
Raises:
| Type | Description |
|---|---|
ValueError
|
If any feature column is non-numeric, which imblearn cannot resample. Encode first. |
Source code in skyulf-core/skyulf/preprocessing/resampling.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
OversamplingCalculator
Bases: BaseCalculator
Configure class balancing by oversampling the minority class.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
fit(_X, _y, config)
Snapshot the sampler settings from config into the artifact.
Neither _X nor _y is read: the artifact is pure configuration,
and the class imbalance it corrects is only observed when the applier
runs the sampler on the training split.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
infer_output_schema(input_schema, config)
Return input_schema untouched.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
316 317 318 319 320 321 | |
UndersamplingApplier
Bases: BaseApplier
Shrink the majority classes with the imblearn under-sampler named in the artifact.
Sees the training split only: :mod:.pipeline excludes the resampling nodes
from apply_on_test/apply_on_validation. That guard matters more here
than for oversampling, because these samplers delete real rows rather than
synthesise new ones.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
apply(X, y, params)
Resample (X, y) with the configured under-sampler.
y is lifted out of X via target_column when not supplied
separately; with no usable target the data passes through untouched, as
it does for a method no builder recognizes.
Raises:
| Type | Description |
|---|---|
ValueError
|
If any feature column is non-numeric, which imblearn cannot resample. Encode first. |
Source code in skyulf-core/skyulf/preprocessing/resampling.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
UndersamplingCalculator
Bases: BaseCalculator
Configure class balancing by undersampling the majority class.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
fit(_X, _y, config)
Snapshot the sampler settings from config into the artifact.
Neither _X nor _y is read: the artifact is pure configuration.
Several of its keys are sampler-specific, so each method consumes only
the subset its imblearn class accepts.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
infer_output_schema(input_schema, config)
Return input_schema untouched.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
464 465 466 467 468 469 | |