holub008 / xrf

eXtreme RuleFit (sparse linear models on XGBoost ensembles)
Other
43 stars 13 forks source link

quiet xgb warnings when prefit #22

Closed simonpcouch closed 2 years ago

simonpcouch commented 2 years ago

A small PR to quiet warnings/errors from xrf.formula about the xgb_control object when passed a prefit_xgb object. Very much appreciating the prefitting option in xrf—allows us tidymodels folks to reuse a lot of machinery for training xgb models.👍

library(xrf)
library(rules) 
#> Loading required package: parsnip
data("ames", package = "modeldata")

# prefit an xgb object
xgb_fit <- 
  xgb_train(
    x = ames[,c("Lot_Area", "Year_Built")],
    y = ames[["Exter_Cond"]]
  )

xrf(
  Exter_Cond ~ Lot_Area + Year_Built,
  data = ames,
  family = "multinomial",
  prefit_xgb = xgb_fit
)
#> [edit: truncating output for brevity]
#> Warning in condition_xgb_control(family, xgb_control, data, response_var):
#> Detected 5 classes to set num_class xgb_control parameter

Created on 2022-06-05 by the reprex package (v2.0.1)

holub008 commented 2 years ago

Glad to hear! 🚢