Missing Value in Target Variable

Viewed 22

I have missing values in my Target Variable (y). Since I want to train my model with more data, I don't want to drop missing rows, instead I'd like to use KNN Imputer algorithm. But also, I'd like to prevent data leakage. So, the best way is to split the data as "train" and "test", then impute the missing target variables in the train dataset (same can be done for missing values in test dataset).

However, I faced with an error:

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

As I understand, the missing values (NaN) have created that specific error.

How to proceed when there are missing values in Target Variable?

1 Answers

Target variable is not advised to be imputed (unless you are sure about the value), this is because they control how the learning algorithm learns. If you already know a value of target variable there is no need for a ML algorithm - right? Therefore, the best way to deal with missing target variable is to delete it. For other missing features, you can use impute strategies.

Related