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

local_event report #39

Closed
bryancoh opened this issue May 29, 2023 · 4 comments
Closed

local_event report #39

bryancoh opened this issue May 29, 2023 · 4 comments
Assignees

Comments

@bryancoh
Copy link

Hi,

  1. I tried to call the function local_event but I am wondering if you consider that the sequences are ordered in ascending order according to the time.
    In my case, sequences are ordered in descending order.
    Example: [event5, event4, event3, event2, event1] where event5 is the last event and event1 is the oldest event
    But when I get the output of local_event function, it looks to be in ascending order.

  2. One more thing, what about the padding? Is there a parameter for that, similar to mask_zero=True

Thank you for your help

@JoaoPBSousa JoaoPBSousa self-assigned this May 31, 2023
@JoaoPBSousa
Copy link
Collaborator

Hi @bryancoh ,

Regarding 1, in TimeSHAP, the assumption is that the sequence follows an ascending order based on time. This means that index 0 of a sequence represents the oldest event, while the last index represents the most recent event. For example: [event1, event2, event3, event4, event5], with event5 being the most recent event.

Regarding 2, TimeSHAP does not require any padding. Each sequence is explained individually, and all perturbations have the same sequence length. This ensures that all batches sent to the model have the same sequence length, eliminating the need for pruning.

I hope this answer is helpful. If you have any further questions feel free to ask.

@bryancoh
Copy link
Author

bryancoh commented Jun 1, 2023

Hi,
Thank you for your answer,
Since in my case the sequence follows a descending order based on time, in order to be able to apply TimeSHAP, should I reverse the report I get from local_event function or should I reverse before applying TimeSHAP.
In case I need to reserve before apply TimeSHAP, it means that I need to change the LSTM model I am using as well.
Thanks.

@JoaoPBSousa
Copy link
Collaborator

Hi @bryancoh ,

Ideally, both TimeSHAP and the model should operate using the same time ordering. However, if this is not possible, you can work around it by modifying the model wrapper. This involves passing the sequence to TimeSHAP in the required order, where the first event of the sequence represents the oldest event. TimeSHAP then sends the sequence to the model wrapper, which flips the time order before passing it to the model. The model scores the sequence, and the wrapper flips the time order of the scores before returning them to TimeSHAP.

Please note that this approach can be considered a workaround, and it introduces multiple potential points of failure in your code. If any part of this wrapper contains a bug, the explanations provided by TimeSHAP will be incorrect.

I hope this answer is helpful. If you have any further questions feel free to ask.

@JoaoPBSousa
Copy link
Collaborator

Closed this issue due to inactivity. If you have any further questions feel free to re-open the issue or create a new one.

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