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
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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
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
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
inference_capability(state, *, engine)
staticmethod
Require the full class distribution; mixed SMOTETomek effects stay unknown.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
335 336 337 338 339 340 341 342 343 | |
validate_inference_state(raw)
staticmethod
Inspect the saved sampler configuration without fitting optional estimators.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
330 331 332 333 | |
OversamplingCalculator
Bases: BaseCalculator
Configure class balancing by oversampling the minority class.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
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
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
infer_output_schema(input_schema, config)
Return input_schema untouched.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
383 384 385 386 387 388 | |
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
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
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
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
inference_capability(state, *, engine)
staticmethod
Require full class context; prediction still skips every sampling method.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
494 495 496 497 498 499 500 501 502 | |
validate_inference_state(raw)
staticmethod
Inspect saved selection settings without loading the optional sampler package.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
489 490 491 492 | |
UndersamplingCalculator
Bases: BaseCalculator
Configure class balancing by undersampling the majority class.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
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
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
infer_output_schema(input_schema, config)
Return input_schema untouched.
Source code in skyulf-core/skyulf/preprocessing/resampling.py
546 547 548 549 550 551 | |