EqualFrequencyBucketer
Bases: BaseBucketer
The EqualFrequencyBucketer
transformer creates buckets with equal number of elements.
Support:
Example:
from skorecard import datasets
from skorecard.bucketers import EqualFrequencyBucketer
X, y = datasets.load_uci_credit_card(return_X_y=True)
bucketer = EqualFrequencyBucketer(n_bins = 10, variables=['LIMIT_BAL'])
bucketer.fit_transform(X)
bucketer.fit_transform(X)['LIMIT_BAL'].value_counts()
Source code in skorecard/bucketers/bucketers.py
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 446 447 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 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 |
|
variables_type
property
¶
Signals variables type supported by this bucketer.
__init__(n_bins=5, variables=[], specials={}, missing_treatment='separate', remainder='passthrough', get_statistics=True)
¶
Init the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_bins |
int
|
Number of bins to create. |
5
|
variables |
list
|
The features to bucket. Uses all features if not defined. |
[]
|
specials |
(nested) dictionary of special values that require their own binning.
The dictionary has the following format:
{" |
{}
|
|
missing_treatment |
Defines how we treat the missing values present in the data.
If a string, it must be one of the following options:
separate: Missing values get put in a separate 'Other' bucket: |
'separate'
|
|
remainder |
How we want the non-specified columns to be transformed. It must be in ["passthrough", "drop"]. passthrough (Default): all columns that were not specified in "variables" will be passed through. drop: all remaining columns that were not specified in "variables" will be dropped. |
'passthrough'
|
Source code in skorecard/bucketers/bucketers.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 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 |
|