Multiple dependent variables

I am using a TabularDataBunch with get_tabular_learner. But to improve my model I need 2 different dependent variables.
Is there any way to do that?

5 Likes

@kardon you should pass an array of dependent variables to .label_from_df(cols=[var_1, var_2])

1 Like

Hi, just curious, were you able to figure out how to do this?

1 Like

Iā€™ve been failing to add multiple dependent variables to @muellerzrā€™s Practical Deep Learning for Coders -> 02 Regression and Permutation Importance (Rossmann Sales).

In-case anyone is interested in checking out his work:

Hereā€™s my problem. I try to replace dep_var in the to TabularPandas part with pyplā€™s suggestion.
to = TabularPandas(train_df, procs, cat_vars, cont_vars,.label_from_df(cols=[dep_var]), y_block=RegressionBlock(), splits=splits, inplace=True, reduce_memory=True)

That returns syntax error: invalid syntax.
In addition, I replaced dep_var with y_names as other notebooks in the same repository seemed to prefer. Failed.

The eventual goal is to add multiple dependent variables. The asset returns and previous year returns (with ā€œ1ā€ after the name are attached on the github noted below.

dep_var =ā€˜infā€™, ā€˜TbondRateā€™, ā€˜TbillRateā€™, ā€˜TbillReturnā€™, ā€˜TbondReturnā€™, ā€˜HomesAverageā€™, ā€˜Oilā€™, ā€˜Goldā€™, ā€˜SPYā€™

Progress in the readme at my github.

You, the fast.ai forums, are my last hope. Could you explain this to my as if Iā€™m an alien baby?

You are not, IIRC I had a tough time with multiple dependent variables as well. If I remember correctly, if they were all regression datatypes it worked fine, I believe for categorical too, but when you mix and match things you get into trouble.

(For the record thatā€™s a bug, and should/will be looked at eventually)

2 Likes

For anyone interested, as Muellerzr suggested I simply passed a list of colums to dependent variables.
dep_vars = ā€˜var1ā€™, ā€˜var2ā€™, ā€˜varā€™
Then switched dep_var for dep_vars in other places in the code.
Notebook from fastai-> fastbook -> 09_tabular

That tabular notebook seems compatible with a very limited information data set such as 10-20 rows.

First though, ā€œNo!:frowning: :face_with_raised_eyebrow: It canā€™t be. Itā€™s too simple.ā€ Anyway, I still have a lot of work to do. But for now, very grateful. :slight_smile:

1 Like

Can someone point to an example of working code?