I have an imputer which has already been fitted. I use it later for imputing missing data before doing classification. The issue is that if e.g. I only impute a single row, it can have missing data. Calling imputer.transform(single_row_df) then fails because some columns don't have any values.
I can make it work by adding one completely defined dummy row, and dropping it after imputation. Here's how I do it in the code:
def impute(self, features):
# First two columns are floats, rest are booleans
features.loc[len(features)] = 2 * [0] + (features.shape[1] - 2) * [True]
X = self.imputer.transform(features)
return X.iloc[:-1]
I have an imputer which has already been fitted. I use it later for imputing missing data before doing classification. The issue is that if e.g. I only impute a single row, it can have missing data. Calling imputer.transform(single_row_df) then fails because some columns don't have any values.
I can make it work by adding one completely defined dummy row, and dropping it after imputation. Here's how I do it in the code:
This solution naturally isn't optimal.
Thanks btw for the great work with the library!