@@ -40,14 +40,25 @@ test_that("compare to dimRed::isomap", {
4040 expect_equal(as.data.frame(pipeop_meta_predict ), dimRed_result_predict @ meta )
4141})
4242
43- test_that(" isomap algorithm requires data to be numeric " , {
43+ test_that(" isomap handles non-numeric features by leaving them untouched " , {
4444 skip_if_not_installed(" dimRed" )
4545 skip_if_not_installed(" RSpectra" )
4646 skip_if_not_installed(" stats" )
4747 po = po(" isomap" )
4848 task = tsk(" penguins" )
4949 task $ filter(which(complete.cases(task $ data())))
50- expect_error(po $ train(list (task )))
50+ non_numeric = task $ feature_types [type %nin % c(" numeric" , " integer" ), id ]
51+ expect_true(length(non_numeric ) > 0 )
52+
53+ trained_task = po $ train(list (task ))[[1 ]]
54+ predicted_task = po $ predict(list (task ))[[1 ]]
55+
56+ expect_true(all(non_numeric %in% trained_task $ feature_names ))
57+ expect_true(all(non_numeric %in% predicted_task $ feature_names ))
58+ expect_equal(trained_task $ data(cols = non_numeric ), task $ data(cols = non_numeric ))
59+ expect_equal(predicted_task $ data(cols = non_numeric ), task $ data(cols = non_numeric ))
60+ expect_true(any(grepl(" ^iso " , trained_task $ feature_names )))
61+ expect_true(any(grepl(" ^iso " , predicted_task $ feature_names )))
5162})
5263
5364test_that(" isomap leaves non-numeric features untouched" , {
0 commit comments