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

Explain CNN for time series classification - possible? #1920

Closed
CCapinha opened this issue Apr 3, 2021 · 6 comments
Closed

Explain CNN for time series classification - possible? #1920

CCapinha opened this issue Apr 3, 2021 · 6 comments
Labels
stale Indicates that there has been no recent activity on an issue

Comments

@CCapinha
Copy link

CCapinha commented Apr 3, 2021

Hi,
thank you for this great work!
Is it possible to apply SHAP for explaining CNN models applied for multivariate time series classification (i.e., i CNN using 3D input - x samples x timesteps x features)?

I found some discussion and examples for RNN/LSTM architectures, but so far could not find an example for CNN. Do you know if this is possible? Any examples (from here or elsewhere) would also be greatly appreciated.
Many thanks in advance.

@ekrell
Copy link

ekrell commented Apr 5, 2021

Also wondering about the use of SHAP for 3D CNN. I have been working with ParititonShap for satellite images: both RGB and 13-band multispectral.

From my understanding, it is not really considering the channels in a 3D way:

  1. When generating the clusters, the depth (z) is always the last to be split.
  2. I have been printing the masks -> they are of shape (height, width, channels) but all channels are identical.
    1. Removing features is performed with OpenCV's blur or inpainting. So, for example, we can't say we want a (3x3x3) blur.
  3. When I check the output SHAP values, there are values for each [row, col, channel] but identical values across the channels for a given pixel.

The partition can be provided as an input instead of generated within the library, but I am not sure that even a partition into cubes will be sufficient since the blurring is 2D. I could be totally wrong, this is just my understanding from exploring the code. Hopefully someone has some insights on working with 3D.

@ekrell
Copy link

ekrell commented Apr 7, 2021

I have spent more time studying the code. I think there is potential for 3D CNN support. Hopefully a dev can weigh in, since I could be totally off.

  1. Partitions are created from the image's row, col, bands as I described. Band-wise splits are at the very bottom of the partition tree.
  2. The set of masks is generated based on the partition tree. The topmost masks divide the image in half (like the partitions) such that the base case of the recursion is a (row, col, band). So masks do include band-wise splits.
  3. How deep our masks go down the partition tree is determined by the max_evals. So first it checks the half-split, then four-way, .... down to the channel-wise splits.
  4. But unless you put a really huge max_splits and are willing to wait a while -> the masks will never get to that level of granularity.

Thus:

  • PartitionShap can use band-wise masks
  • But the partition scheme is such that we are unlikely to use band-granular masks
  • But we can specify our own partition scheme instead of relying on the built-in. Pretty sure it is an optional argument.
  • I need to think more about the impact of 2D blurring on band-wise SHAP...

@ekrell
Copy link

ekrell commented Apr 16, 2021

Check this PR: #1944

I only added a channel-first partition scheme and a way to view the channel-wise SHAP values. But you can check what I did and see if it is at all useful to use or build off of. I would be very interested if you have success with 3D CNN SHAP values!

@CCapinha
Copy link
Author

Many thanks, Evan. It's a pretty great addition already! Will send you feedback asap.

Copy link

This issue has been inactive for two years, so it's been automatically marked as 'stale'.

We value your input! If this issue is still relevant, please leave a comment below. This will remove the 'stale' label and keep it open.

If there's no activity in the next 90 days the issue will be closed.

@github-actions github-actions bot added the stale Indicates that there has been no recent activity on an issue label Feb 12, 2024
Copy link

This issue has been automatically closed due to lack of recent activity.

Your input is important to us! Please feel free to open a new issue if the problem persists or becomes relevant again.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Indicates that there has been no recent activity on an issue
Projects
None yet
Development

No branches or pull requests

2 participants