Correct code for imputation with fancyimpute

201 Views Asked by At

I was performing an imputation of missing values by KNN with this code:

1) data[missing] = KNN(k = 3, verbose = False).fit_transform(data[missing])

However, I saw some tutorials (e.g. Chris Albon - Machine Learning With Python Cookbook p. 78) that used the method .complete();

2) features_knn_imputed = KNN(k=5, verbose=0).complete(X_train[true_nums])

I was wondering if 2) is deprecated code or if my implementation of KNN for imputing in 1) is incorrect?

1

There are 1 best solutions below

0
Sea On BEST ANSWER

Yes, .complete is deprecated. Use .fit_transform just like sklearn.

Check the usage here: https://pypi.org/project/fancyimpute/0.5.5/