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

bin function end, some statement can be a function && others. #3

Closed
IvanaXu opened this issue Jun 1, 2020 · 2 comments
Closed

bin function end, some statement can be a function && others. #3

IvanaXu opened this issue Jun 1, 2020 · 2 comments

Comments

@IvanaXu
Copy link

IvanaXu commented Jun 1, 2020

  • bin function end, some statement can be a function.

py_mob/py_mob/py_mob.py

Lines 293 to 309 in cda0147

for _ in _l5:
if _["bin"] == 0:
_["rule"] = "numpy.isnan($X$)"
elif _["bin"] == len(_l3) + 1:
if _["miss"] == 0:
_["rule"] = "$X$ > " + str(_l3[-1])
else:
_["rule"] = "($X$ > " + str(_l3[-1]) + ") or numpy.isnan($X$)"
elif _["bin"] == 1:
if _["miss"] == 0:
_["rule"] = "$X$ <= " + str(_l3[0])
else:
_["rule"] = "($X$ <= " + str(_l3[0]) + ") or numpy.isnan($X$)"
else:
_["rule"] = "($X$ > " + str(_l3[_["bin"] - 2]) + ") and ($X$ <= " + str(_l3[_["bin"] - 1]) + ")"
_sel = ["bin", "freq", "miss", "bads", "rate", "woe", "iv", "rule"]

  • Nice.

py_mob/py_mob/py_mob.py

Lines 189 to 190 in cda0147

_l1 = sorted(zip(_g, _x, _y), key = lambda x: x[0])
_l2 = zip(set(_g), [[l for l in _l1 if l[0] == g] for g in set(_g)])

  • trying to run data.

  • BTW, the new bin function(kmn_bin、gbm_bin) it is great.

@statcompute
Copy link
Owner

I agree. the rule parsing is not compact. let me think about it and see if it can be wrapped into a function.

@IvanaXu IvanaXu closed this as completed Jun 1, 2020
@statcompute
Copy link
Owner

generating rules has been wrapped in a function in the updated version. thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants