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

pdp_isolate fails for regression tasks #1

Closed
NMRobert opened this issue Aug 2, 2017 · 3 comments
Closed

pdp_isolate fails for regression tasks #1

NMRobert opened this issue Aug 2, 2017 · 3 comments

Comments

@NMRobert
Copy link

NMRobert commented Aug 2, 2017

Hi - firstly I'd like to thank you for producing this package, it's really great! I was just reading the ICEBox paper recently and was considering building something, but was delighted to see somebody else already had :)

I'm having issues with calling pdp_isolate on a regression model - it throws the following exception:

usr/local/lib/python3.5/dist-packages/PDPbox-0.1-py3.5.egg/pdpbox/pdp.py in pdp_isolate(model, train_X, feature, num_grid_points, percentile_range)
    113     # store the ICE lines
    114     # for multi-classifier, a dictionary is created
--> 115     if n_classes > 2:
    116         ice_lines = {}
    117         for n_class in range(n_classes):

TypeError: unorderable types: NoneType() > int()

Even the 'Regression.ipynb' example in PDPbox/test/Regression/ does this. A cursory glance at the codebase seems to suggest that when we have a sklearn model without a classes property, n_classes gets set to None on pdp.py line 64. Then all subsequent comparisons of n_classes to an integer will throw this error. Any suggestions?

@SauceCat
Copy link
Owner

SauceCat commented Aug 3, 2017

Hi @NMRobert,

Thanks for informing the issue!
I notice that you are using Python3, while I used Python2 when I built the package. So the issue might be, rules are stricter in Python3. For example, you can't compare None with an integer. And this is the reason why you got the error. Because when the model is not a classifier, I set n_classes equal to None. Now I have changed it to 0. So now everything should be fine. 😸
It is so good to have someone help test PDPbox using Python3. If you find any issues in the further, feel free to open an issue.

@NMRobert
Copy link
Author

NMRobert commented Aug 3, 2017

Great - I suspected it might be a python 2/3 issue! Your fix resolves the issue on the call in question.

I have found at least 1 more python3 related issue, would you prefer I open individual tickets for them, or collate everything in one place once I've found a couple? Cheers.

@SauceCat
Copy link
Owner

SauceCat commented Aug 3, 2017

@NMRobert,
I think it is great to collect everything in one place and I will try to fix them.
Thank you so much! 💯

@SauceCat SauceCat closed this as completed May 9, 2018
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