topepo / caret

caret (Classification And Regression Training) R package that contains misc functions for training and plotting classification and regression models
http://topepo.github.io/caret/index.html
1.61k stars 634 forks source link

classDist test is flaky #1352

Open MichaelChirico opened 11 months ago

MichaelChirico commented 11 months ago

https://github.com/topepo/caret/blob/5f4bd2069bf486ae92240979f9d65b5c138ca8d4/pkg/caret/tests/testthat/test_classDist.R#L64

res <- replicate(1e4, {
  trainSet <- sample(1:150, 100)
  x = iris[trainSet, 1:4]
  y = as.numeric(iris$Species[trainSet])
  groups = 4

  distData <- classDist(x, y, pca = FALSE, groups = groups)
  length(distData$values) == length(unique(y)) - 1
})
table(res)
# res
# FALSE  TRUE 
#    21  9979 

How can we decrease the flakiness here?