marjoleinF / pre

an R package for deriving Prediction Rule Ensembles
58 stars 17 forks source link

Bug fixes and more #7

Closed boennecd closed 7 years ago

boennecd commented 7 years ago

Changes

The latter means that this test passes:

test_that("Predict gives previous results with airquality data", {
  set.seed(42)
  airq.ens <- pre(Ozone ~ ., data=airquality, ntrees = 10)
  preds <- predict(airq.ens, airquality)

  #####
  # Should give the same if the same data is passed to newdata as used to fit
  other_preds <- predict(airq.ens)
  expect_equal(other_preds, preds)
})

In other words, you get the same predicted results for the initial data both with the function and by calling predict. Further, the new function to get the model.matrix will also work if the user, for some reason, have dropped the factor levels for one newdata's columns in the argument to predict and other edge cases.