mlr-org / mlr3learners

Recommended learners for mlr3
https://mlr3learners.mlr-org.com
GNU Lesser General Public License v3.0
91 stars 16 forks source link

kknn should give an informative error message when missing values lead to an error #175

Closed mb706 closed 3 years ago

mb706 commented 3 years ago
> l <- lrn("classif.kknn")$train(tsk("pima"))
> l$predict(tsk("pima"))
Error in check_prediction_data.PredictionDataClassif(pdata) : 
  Assertion on 'as_factor(pdata$response, levels = lvls)' failed: Must have length 768, but has length 392.

Pretty sure this is because of missing values (kknn just ignores them and creates a prediction for the rows that don't contain missing values), the error message should make this clear.

Maybe this is a good time to lobby for splitting up the 'missing' property into train-missing and predict-missing or smth like that.

mllg commented 3 years ago

We now throw an exception during train.