A walk with fastai2 - Tabular - Study Group and Online Lectures Megathread

There is no .process() for a DataLoader generated from your ‘original’ dl used in training (as in a dl created from calling dls.test_dl). You can do that for your training dl though. Even after calling .process() and then creating a new .test_dl using my test data, the dataset is still unencoded (which makes sense, but I just wanted to mention that).

fastai2 version: 0.0.17
fastcore version: 0.1.17

Hi!

Do any of these notebooks contain an example of regression with multiple dependent variables? I am not sure exactly how to proceed.

Thanks!

No, I’m afraid they don’t out of the box. TabularPandas doesn’t like that very much. My best recommendation would be using a NumPy DataLoader for tabular instead and working with it. See my article here @vrodriguezf https://muellerzr.github.io/fastblog/2020/04/22/TabularNumpy.html

Thank you, I’ll have a look! However, I am a bit confused. I just created a TabularDataLoaders with a list of two variables as y_names, and y_block=RegressionBlock(), and things seem to be working with MSE as loss function.

I did not even need to adjuts the n_out argument of RegressionBlock, which I was thinking at the beginning that could be used to define the number of output activations that you wanted in the regression.

You found the one exception :wink: if it’s two regressions it will work. However classification with regression or two classifications it will not

1 Like

Oh, I understand! how lucky I am :slight_smile:

One extra question: I am not sure if I remember correctly, but: did fastai1 provide a way to automatically log transform the dependent variables? Is that provided as a ready-to-use Procs in fastai2?

EDIT: Sorry I just saw that Jeremy does it manually in one of the fastai2 lessons

Correct. V1 did, v2 doesn’t

Hi again!

Is there an equivalent of plot_top_losses for a tabular learner?

Thanks!

Should work out of the box on any Interpretation object :slight_smile: (ClassificationInterpretation or otherwise)

strange, I manage to get plot_confusion_matrix working, but not plot_top_losses(k=10). It does not raise any error, it just doesn’t show up anything

Hmmm. I’ll take a look at it on my end shortly :slight_smile:

In the meanwhile I am using the show method from TabularPandas, but instead of using the whole validation dataset, I manually subset it with the indices given by Interpretation.top_losses:

def show_top_losses(tab_learner, k=None, largest=True):
  interp = Interpretation.from_learner(tab_learner)
  top_losses = interp.top_losses(k, largest)
  to_top_losses = tab_learner.dls.valid.dataset.iloc[top_losses.indices]
  to_top_losses.show()
  return to_top_losses

EDIT: This workaround just shows the rows associated to the top losses, but not the losses neither the predictions

@vrodriguezf the issue comes with _pre_show_batch. It’s not returning the y's or the outs as it should be. I’ll file a bug report :slight_smile: (As @sgugger may not be able to get to this for a bit). In the meantime nice workaround!

Thanks a lot @muellerzr!!! I look forward to seeing the fix.

1 Like

@vrodriguezf Re: GitHub issue: currently not implemented, Sylvain will look at it when he has time (and isn’t doing the edits :wink: )

Good to know! thank you for raising the issue :wink:

Basic question about intepretability: Can fastshap be used for a regression learner? Should I use the premutation importance class instead?

You should be able to use it for regression IIRC (it was a collaboration project and I believe we tackled it). Otherwise, yes permutation importance would be good to use too always :slight_smile: I can’t recall if I had it set up specifically for classification or not, but it should be straightforward to adjust for regression too (just adjust what metric/loss function it’s using to generate it’s differences and possibly change how it uses them. IE MSE should favor a smaller number vs hinder such as accuracy)

Out of the box, calling ShapInterpretation with a regression learner raises an error due to the attribute vocab is not there :S

1 Like

I’ll look at it when I have time, thanks! :slight_smile: