1

我试图将套索模型应用于我创建的食谱(使用recipes包),但出现错误:

NAs由
lognet(xd, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : NA/NaN/Inf in foreign function call (arg 5) 中的强制错误引入

这是我创建的食谱:

c_recipe <- recipe(c ~ ., 
                   data = train) %>%
  step_rm(customer_id, billing_postal, billing_address,billing_city) %>%
  step_novel(all_nominal_predictors()) %>%
  step_impute_mean(all_numeric_predictors()) %>%
  step_impute_mode(all_nominal_predictors()) %>%
  step_normalize(all_numeric_predictors()) %>%
  step_dummy(all_nominal_predictors()) %>%
  step_zv(all_predictors())

c_recipe

这是我应用模型的方式:

lasso_spec <- logistic_reg(penalty = 0.1, mixture = 1) %>%
  set_mode("classification") %>%
  set_engine("glmnet")

logistic_wf <- workflow() %>%
  add_recipe(churn_recipe) %>%
  add_model(lasso_spec) %>%
  fit(train)
4

0 回答 0