2

I get this error when using the "explain" function from the "lime" library on a h2o random forest.

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

I can't find documentation online, or help about this question online. Can you help me root-cause and resolve it?

Here is my code:

explainer_h2o_rf  <- lime(x=big_df, 
                          model=fit_rf.hex, 
                          bin_continuous = FALSE,
                          use_density = T, 
                          quantile_bins = F)

# for(i in 1:25){
i <- c(1,2)
explanation_rf <- explain(x = x_lime[i,],
                          explainer = explainer_h2o_rf,
                          n_features = 15,
                          feature_select = "auto",
                          labels = "1")

Notes:

  • I am predicting a binomial variable within the h2o model, 'fit_rf.hex'.
  • I worked through this and it worked, but my current approach does not
  • The "lime" tag does not seem to apply to this lime library, but to something that is used for unit testing.
  • The non-gaussian shouldn't be a problem, because (I think) I have set the flags that deal with non-gaussian (nearly all my data is non-Gaussian) data using kernel methods.

Here are sites/questions that didn't contain my answer:

EngrStudent
  • 1,924
  • 31
  • 46
  • Please modify your code example to make it reproducible (it's missing data). – Erin LeDell Jun 28 '18 at 18:57
  • @ErinLeDell - It is proprietary, so that can't happen. If you have a particular question about the nature of the data I might be able to help. – EngrStudent Jun 28 '18 at 20:13
  • 1
    You don't need to post the proprietary data, but you do need to post an example that replicates the issue on a public dataset. The first step of debugging is reproducing the error. – Erin LeDell Jun 28 '18 at 22:10
  • @ErinLeDell - The cheapest reproduction is one someone else already did, which happens with known/common errors, which I was hoping for. I can work on trying to replicate this error in a different set of data, but I'm going to have to get lucky, and it is going to take time. – EngrStudent Jun 29 '18 at 13:27

2 Answers2

1

Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, :

y is constant; gaussian glmnet fails at standardization step

Just reading the error, there seems to be a problem with your training data, or possibly some subset of the data that is used to train a glmnet model (elnet() is used inside the glmnet() function).

Specifically, the error indicates that the response column is constant and therefore cannot train an glmnet model -- training a glmnet model is a step inside the model_permutations() function, which itself is inside the explain() function.

You should check your response column to make sure that it's not constant.

Community
  • 1
  • 1
Erin LeDell
  • 8,704
  • 1
  • 19
  • 35
1

I was getting a similar error.

I changed labels = "Yes" to labels = "Response", to match my target variable which resolved my issue.

M--
  • 25,431
  • 8
  • 61
  • 93