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

NativeGuideCF(method=NG) can return a CF of the same class. #37

Closed
hugo-rddi opened this issue Aug 22, 2023 · 3 comments
Closed

NativeGuideCF(method=NG) can return a CF of the same class. #37

hugo-rddi opened this issue Aug 22, 2023 · 3 comments

Comments

@hugo-rddi
Copy link

Hello,
As is it mentioned in this issue's title, I have tried many times the current CF generation in this configuration, and it often generates a CF of the same label than the one predicted already by the the model.

Hope the issue is clear enough !
Thanks

@hugo-rddi hugo-rddi changed the title NativeGuide(method=NG) can return a CF from the same class. NativeGuide(method=NG) can return a CF of the same class. Aug 22, 2023
@hugo-rddi hugo-rddi changed the title NativeGuide(method=NG) can return a CF of the same class. NativeGuideCF(method=NG) can return a CF of the same class. Aug 22, 2023
@JHoelli
Copy link
Contributor

JHoelli commented Aug 23, 2023

Hi,

Looking at your last issue, I think the issue might have been that the input for y into the explain function is an array, although it is supposed to be an int.
I rechecked the code and their is a small error in the notebooks for NunCF. I fixed that error and made NG more robust by changing some of the preprocessing code.

You can try it with:
pip install https://github.com/fzi-forschungszentrum-informatik/TSInterpret/archive/refs/heads/ng_test.zip

or instead by adding:

cf_ts, cf_label = exp_model.explain(
    input_x,
    np.argmax(y_target, axis=1)**[0]**
)

Let me know if it works or if you still need help.

@hugo-rddi
Copy link
Author

Hi again,
Thanks you're right.

The only case where your fix won't be enough is a very bad classifier f that predicts C for every input. In this scenario, the nearest neighbour will always be from a similar predicted class and method=NG returns a CF within the same class. An idea could be to have a "No CF found" message as it can be the case for method=dtw-barycenter ... ?

Anyway, thanks for your help.
Have a nice day !

@JHoelli
Copy link
Contributor

JHoelli commented Aug 23, 2023

Indeed, that's a really good point. I added a warning that will be available in the next release.

Have a good day.

@JHoelli JHoelli closed this as completed Aug 23, 2023
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