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

py_mob func iso_bin, IndexError For List. #2

Closed
IvanaXu opened this issue May 21, 2020 · 2 comments
Closed

py_mob func iso_bin, IndexError For List. #2

IvanaXu opened this issue May 21, 2020 · 2 comments

Comments

@IvanaXu
Copy link

IvanaXu commented May 21, 2020

py_mob/py_mob/py_mob.py

Lines 393 to 427 in 91ff2a2

_p = sorted([_[1] for _ in [l for l in _l3 if l[2] < 1 and l[2] > 0 and l[3] > 10]])[1:-1]
_l4 = sorted(manual_bin(_x, _y, _p), key = lambda x: x["bads"] / x["freq"])
if len([_ for _ in _data if _[2] == 0]) > 0:
_m1 = miss_bin([_[1] for _ in _data if _[2] == 0])
if _m1["bads"] == 0:
for _ in ['freq', 'miss', 'bads']:
_l4[0][_] = _l4[0][_] + _m1[_]
elif _m1["freq"] == _m1["bads"]:
for _ in ['freq', 'miss', 'bads']:
_l4[len(_l4) - 1][_] = _l4[len(_l4) - 1][_] + _m1[_]
else:
_l4 = [_m1] + _l4
_l5 = sorted([{**_,
"rate": round(_["bads"] / _["freq"], 4),
"woe" : round(numpy.log((_["bads"] / _bads) / ((_["freq"] - _["bads"]) / (_freq - _bads))), 4),
"iv" : round((_["bads"] / _bads - (_["freq"] - _["bads"]) / (_freq - _bads)) *
numpy.log((_["bads"] / _bads) / ((_["freq"] - _["bads"]) / (_freq - _bads))), 4)}
for _ in _l4], key = lambda x: x["bin"])
for _ in _l5:
if _["bin"] == 0:
_["rule"] = "numpy.isnan($X$)"
elif _["bin"] == len(_p) + 1:
if _["miss"] == 0:
_["rule"] = "$X$ > " + str(_p[-1])
else:
_["rule"] = "($X$ > " + str(_p[-1]) + ") or numpy.isnan($X$)"
elif _["bin"] == 1:
if _["miss"] == 0:
_["rule"] = "$X$ <= " + str(_p[0])
else:
_["rule"] = "($X$ <= " + str(_p[0]) + ") or numpy.isnan($X$)"

 _p = sorted([_[1] for _ in [l for l in _l3 if l[2] < 1 and l[2] > 0 and l[3] > 10]])[1:-1] 

if sorted([_[1] for _ in [l for l in _l3 if l[2] < 1 and l[2] > 0 and l[3] > 10]]) is short than 3
just like [0, 1], cut [1:-1] to _p will be []

_["rule"] = "$X$ > " + str(_p[-1]) 

or

_["rule"] = "$X$ <= " + str(_p[0])

will be

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
@statcompute
Copy link
Owner

try below if it can fix the issue:
p = sorted([[1] for _ in [l for l in _l3 if l[2] < 1 and l[2] > 0 and l[3] > 3]])[:-1]

Thanks

@statcompute
Copy link
Owner

statcompute commented May 23, 2020

The issue should have been fixed in the version 0.2.1 published on 05/23/2020.

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