11test_that(" predict on newdata works / clust" , {
22 task = tsk(" usarrests" )$ filter(1 : 40 )
3- learner = lrn(" clust.featureless" )
4- learner $ param_set $ values = list (num_clusters = 1L )
3+ learner = lrn(" clust.featureless" , num_clusters = 1L )
54 expect_error(learner $ predict(task ), " trained" )
65 learner $ train(task )
76 expect_task(learner $ state $ train_task )
@@ -15,26 +14,24 @@ test_that("predict on newdata works / clust", {
1514
1615 # rely on internally stored task representation
1716 p = learner $ predict_newdata(newdata = newdata , task = NULL )
18- expect_data_table(as.data.table(p ), nrows = 10 )
17+ expect_data_table(as.data.table(p ), nrows = 10L )
1918 expect_set_equal(as.data.table(p )$ row_ids , 1 : 10 )
2019 expect_null(p $ truth )
2120})
2221
2322test_that(" reset()" , {
2423 task = tsk(" usarrests" )
25- lrn = lrn(" clust.featureless" )
26- lrn $ param_set $ values = list (num_clusters = 2L )
24+ learner = lrn(" clust.featureless" , num_clusters = 2L )
2725
28- lrn $ train(task )
29- expect_list(lrn $ state , names = " unique" )
30- expect_learner(lrn $ reset())
31- expect_null(lrn $ state )
26+ learner $ train(task )
27+ expect_list(learner $ state , names = " unique" )
28+ expect_learner(learner $ reset())
29+ expect_null(learner $ state )
3230})
3331
3432test_that(" empty predict set (#421)" , {
3533 task = tsk(" usarrests" )
36- learner = lrn(" clust.featureless" )
37- learner $ param_set $ values = list (num_clusters = 1L )
34+ learner = lrn(" clust.featureless" , num_clusters = 1L )
3835 resampling = rsmp(" holdout" , ratio = 1 )
3936 hout = resampling $ instantiate(task )
4037 model = learner $ train(task , hout $ train_set(1 ))
0 commit comments