0
$\begingroup$

I'm dealing with a multi-output regression problem (~ 800 dependent variables, ~ 1300 observations). My current approach is to train a single model for each output. To select an "optimal" lambda I tried to use cv.glmnet, but the training fails as some targets occured only a few (e. g. 2-5) times in the past (the other instances are 0 for this target). If this is the case, I need to force these instances to be present in each fold (some kind of stratified sampling). Otherwise there's a high probability that there's no variation in y and cv.glmnet produces following error message:

Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : y is constant; gaussian glmnet fails at standardization step.

How can I make sure / control that those observations are in each fold if the number of instances for a specific target is small?

$\endgroup$
1
$\begingroup$

If i have understand your problem statement, then Stratified sampling can help you tuning the hyperparameter(lambda).

Another(& Best), you can directly obtained the expression for the weight matrix with different lambda and tune for that.

Note: Just treat this problem as many linear regression problem, each with its own lambda.

$\endgroup$
1
$\begingroup$

If I understand your question correctly, you have 1300 observations. For some of your outputs, 1295 of 1300 observation have the value zero and 5 obervations have a value $\neq$ 0. Treated independently, you won't create a meaningful regression model for these outputs. Your problem is not with cross-validation, your problem is the extremly unbalanced data set. For now, I would advice to build a regression model only for the outputs where you have sufficent variance in data to do so. For all other outputs, maybe you can group them into one binary variable with $0:$ "all values are zero" and thereby generate enough $1$s to solve a classification problem. Or you just need to get more data...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.