toad.scorecard module

class toad.scorecard.ScoreCard(pdo=60, rate=2, base_odds=35, base_score=750, card=None, combiner={}, transer=None, **kwargs)[source]

Bases: sklearn.base.BaseEstimator, toad.utils.mixin.RulesMixin, toad.utils.mixin.BinsMixin

__init__(pdo=60, rate=2, base_odds=35, base_score=750, card=None, combiner={}, transer=None, **kwargs)[source]
Parameters:
  • combiner (toad.Combiner) –
  • transer (toad.WOETransformer) –
coef_

coef of LR model

fit(X, y)[source]
Parameters:
  • X (2D DataFrame) –
  • Y (array-like) –
predict(X, **kwargs)[source]

predict score :param X: X to predict :type X: 2D-DataFrame|dict :param return_sub: if need to return sub score of each feature :type return_sub: Bool :param default: default sub score for unknown feature, min`(default), `max :type default: str|number

Returns:predicted score DataFrame|dict: sub score for each feature
Return type:array-like
get_reason(X, base_effect=None, threshold_score=None, keep=3)[source]

calculate top-effect-of-features as reasons

Parameters:
  • X (2D DataFrame) – X to find reason
  • base_effect (Series) – base effect score of each feature
  • threshold_score (float) – threshold to find top k most important features, show the highest top k features when prediction score > threshold and show the lowest top k when prediction score <= threshold default is the sum of base_effect score
  • keep (int) – top k most important reasons to keep, default 3
Returns:

top k most important reasons for each feature

Return type:

DataFrame

bin_to_score(bins, return_sub=False, default='min')[source]

predict score from bins

predict_proba(X)[source]

predict probability

Parameters:X (2D array-like) – X to predict
Returns:probability of all classes
Return type:2d array
proba_to_score(prob)[source]

covert probability to score

odds = (1 - prob) / prob score = factor * log(odds) * offset

score_to_proba(score)[source]

covert score to probability

Returns:the probability of 1
Return type:array-like|float
woe_to_score(woe, weight=None)[source]

calculate score by woe

after_load(rules)[source]

after load card

after_export(card, to_frame=False, to_json=None, to_csv=None, **kwargs)[source]

generate a scorecard object

Parameters:
  • to_frame (bool) – return DataFrame of card
  • to_json (str|IOBase) – io to write json file
  • to_csv (filepath|IOBase) – file to write csv
Returns:

dict

testing_frame(**kwargs)[source]

get testing frame with score

Returns:testing frame with score
Return type:DataFrame