testSources.R 821 B

123456789101112131415161718192021222324252627282930313233
  1. context("Importance source tests")
  2. set.seed(777)
  3. data(srx)
  4. X<-srx[,-ncol(srx)]
  5. Y<-srx$Y
  6. #Also a numeric nonsense feature, for more fun
  7. X$N4<-runif(nrow(X))
  8. impSources<-c(
  9. "getImpExtraGini","getImpExtraRaw","getImpExtraZ","getImpFerns",
  10. "getImpLegacyRfGini","getImpLegacyRfRaw","getImpLegacyRfZ",
  11. "getImpRfGini","getImpRfRaw","getImpRfZ") #getImpXgboost is special
  12. for(e in impSources)
  13. test_that(sprintf("Importance source %s works",e),{
  14. set.seed(777)
  15. #Run Boruta on this data
  16. Boruta(X,Y)->ans
  17. #Nonsense attributes should be rejected
  18. expect_equal(
  19. sort(getSelectedAttributes(ans)),
  20. sort(c('A','B','AnB','AoB','nA'))
  21. )
  22. })
  23. test_that("Importance source getImpXgboost works",{
  24. set.seed(777)
  25. #Xgboost importance is generally poor, lower expectations
  26. expect_silent(Boruta(Species~.,data=iris))
  27. })