timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
5.1k stars 639 forks source link

feature_importance throwing an error #632

Closed alitirmizi23 closed 1 year ago

alitirmizi23 commented 1 year ago

I'm trying to plot top losses as well as feature importance but both keep throwing the same error: AttributeError: 'list' object has no attribute 'astype'

The learner is trained and the data is in the shape of n_samples, features, timesteps as an ndarray. Any ideas why this would be happening?

learn.feature_importance()

oguiza commented 1 year ago

Could you please provide a code snippet to reproduce this error? I recently tested this functionality and it was working well.

alitirmizi23 commented 1 year ago

Apologies but I won't be able to because of confidentiality. However, I see that both feature_importance() and plot_top_losses() have some sort of bug related to the batch size. I can get the feature_importance() to work after passing samples equal to the batch_size parameter, but for the plot_top_losses(), it doesn't work in any way at all!

The workflow looks like below:


learn = ts_learner(dls, InceptionTime , metrics=[mae], cbs=ShowGraph())

with ContextManagers([learn.no_logging()]): 
    learn.fit_one_cycle(250, 0.02)
learn.plot_metrics()

learn.feature_importance(X[splits[1]][0:64]) # throws error if i don't pass in 64 samples, which is equal to the default batchsize  # parameter in feature_importance

learn.plot_top_losses() # throws error no matter what i try
oguiza commented 1 year ago

Hi @alitirmizi23 , I have not been able to reproduce the issue, so I'm sorry but I won't be able to help you. I'd need 2 things:

oguiza commented 1 year ago

Closing this issue due to lack of activity and progress. If necessary please, create a new one.