Anyone use SHAP for nhits/nbeats explainability? I...
# neural-forecast
a
Anyone use SHAP for nhits/nbeats explainability? I'm trying to get it to work but keep running into a bunch of errors. Was wondering if this is even possible. I found this in the SHAP documentation describing how to use SHAP with pytorch data, so i did the same thing but run into an error saying
IndexError: too many indices for tensor of dimension 3
. My data is a simple 3 column dataframe with
ds
,
unique_id
, and
y
as columns, and unique_id having 99 different values
Copy code
dataset, *_ = TimeSeriesDataset.from_df(test_df)
loader = TimeSeriesLoader(dataset, batch_size=33, shuffle=False)
batch = next(iter(loader))

ts = batch['temporal']

ex = shap.DeepExplainer(nhits, ts)
c
Hi Ali! We will add the functionality to nf soon. The easiest way is to use the
KernelExplainer
. You need to create a parsing function that parses the current
df
input data. The new data must have each size window
input_size
on a different row. You also need a function that takes each row and passes it to the forward method of a
nf
model.
👍 1
a
Thanks Cristian. Let me give that a try
a
Hey @Ali Khanafer, did you manage to implement it by any chance? 🙂
a
Nope. Spent a long while on it before I gave up. There are too many differences in the input assumptions made between the two libraries to get it to work out of the box. But please let me know if you figure it out
a
Thanks for your quick answer Ali! If I manage to make it work, I will let you know!
👍 1
r
I am also interested in using SHAP on N-HiTS/N-BEATS trained models. Let me know if you make any progress in this end.
👍 1