Skip to content

Instantly share code, notes, and snippets.

@sazio
Created August 29, 2020 12:11
Show Gist options
  • Save sazio/6ae18b9038fc612c456dd0d9d5865cfc to your computer and use it in GitHub Desktop.
Save sazio/6ae18b9038fc612c456dd0d9d5865cfc to your computer and use it in GitHub Desktop.
import numpy as np
from sklearn.impute import KNNImputer
X = [[1, 2, np.nan], [3, 4, 3], [np.nan, 6, 5], [8, 8, 7]]
imputer = KNNImputer(n_neighbors=2, weights="uniform")
print(X)
print(imputer.fit_transform(X))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment