Does fastai.tabular use the dep_var to predict dep_var?

Does fastai.tabular use the dep_var to predict dep_var???
The predict function needs all the columns of dataframe to work (which includes the dep_var) and if you change the given dep_var to it, sometimes the returned value changes accordingly!!!
Why does it need the dep_var as part of input for the predict function?

When you set up your initial databunch object for training, did you include your dependent variable anywhere in your categorical or continuous variables by accident?

Yes, Shouldn’t I? My dep_var is a categorical variable!

That’s what’s happening. No, what we declare in cat_var and cont_var are the independant variables of said types so we can keep them separate.

My dep_var is of type integer, but it is a class label, then how should I tell fastai that its a class label

Hi Ramin,

You should be able to label your dep_var as “CategoryList”, fastai should then treat it as a single class label. Have a look at the relevant docs here. If your dep_var is already of type integer (not float), then I believe fastai will already default to treating it as categorical (i.e. single class). Thanks.


Hi @ramin,
If your dep_var is categorical, you do not need to mention it explicitly.
But for regression problems you need to specify it when you create labels for your databunch like so :
.label_from_df(cols=dep_var, label_cls=FloatList)

I think lesson 6 covers the topic in details.
Hope this helped