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