Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] argument metric_missing=0 is ignored when points for missing cat is calculated in scorecard table #226

Closed
peterpanmj opened this issue Dec 18, 2022 · 1 comment
Labels
bug Something isn't working
Projects
Milestone

Comments

@peterpanmj
Copy link
Contributor

description

Scorecard._fit will ignore the metric_missing=0 parameter, when build scorecard. I

example

data = pd.DataFrame(
    data = {'target': np.hstack(
        (np.random.choice([0, 1], 100, p=[0.1, 0.9]),
         np.random.choice([0, 1], 100, p=[0.9, 0.1])
        )),
    'var':[np.nan]*100+['A']*100
    }
)

scorecard3 = Scorecard(binning_process=binning_process, 
                       estimator=LogisticRegression(),
                       scaling_method="min_max",
                       scaling_method_params=scaling_method_params
                      ).fit(data, data.target,metric_missing=0, metric_special=0)

print(scorecard3.table(style='detailed'))

current behaviour

scorecard3.table(style='detailed') is some positive number, however the actual result should be zero, since there are only two bins . So one bin gets 100 and the other get 0.

expected results

by simply configure metric_special='empirical', will give the correct results, even though there is no special cases in the data or in the binning_process

scorecard1 = Scorecard(binning_process=binning_process,
                       estimator=LogisticRegression(),
                       scaling_method="min_max",
                       scaling_method_params=scaling_method_params
                      ).fit(data, data.target,metric_missing=0, metric_special='empirical')

print(scorecard1.table(style='detailed'))

I have a fix for that. It is actually quite obvious. The source code just ignored the argument metric_missing when metric_special !='empirical' However I found no docs about where and how to put new tests in this project. Can anyone give me some info ?

@guillermo-navas-palencia
Copy link
Owner

Thank you @peterpanmj. I commented on the pull request.

@guillermo-navas-palencia guillermo-navas-palencia added the bug Something isn't working label Dec 18, 2022
@guillermo-navas-palencia guillermo-navas-palencia added this to the v0.17.3 milestone Dec 18, 2022
guillermo-navas-palencia added a commit that referenced this issue Jan 15, 2023
fix metric_missing=0 is ignored in Scorecard._fit #226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
ToDo
  
Awaiting triage
Development

No branches or pull requests

2 participants