Skip to content

Instantly share code, notes, and snippets.

@YohanObadia
YohanObadia / knn_impute_example.py
Created Feb 4, 2017
Example of use for the knn_impute function
View knn_impute_example.py
knn_impute(target=df['Age'], attributes=df.drop(['Age', 'PassengerId'], 1),
aggregation_method="median", k_neighbors=10, numeric_distance='euclidean',
categorical_distance='hamming', missing_neighbors_threshold=0.8)
@YohanObadia
YohanObadia / knn_impute_example.py
Created Feb 4, 2017
Example of use for the knn_impute function
View knn_impute_example.py
knn_impute(target=df['Age'], attributes=df.drop(['Age', 'PassengerId'], 1),
aggregation_method="median", k_neighbors=10, numeric_distance='euclidean',
categorical_distance='hamming', missing_neighbors_threshold=0.8)
@YohanObadia
YohanObadia / knn_impute.py
Last active Nov 19, 2020
Imputation of missing values with knn.
View knn_impute.py
import numpy as np
import pandas as pd
from collections import defaultdict
from scipy.stats import hmean
from scipy.spatial.distance import cdist
from scipy import stats
import numbers
def weighted_hamming(data):
You can’t perform that action at this time.