Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Nearest neighbors imputation

# Nearest neighbors imputation

import numpy as np
from sklearn.impute import KNNImputer
nan = np.nan
X = [[1, 2, nan], [3, 4, 3], [nan, 6, 5], [8, 8, 7]]
imputer = KNNImputer(n_neighbors=2, weights="uniform")
imputer.fit_transform(X)
# array([[1. , 2. , 4. ],
#        [3. , 4. , 3. ],
#        [5.5, 6. , 5. ],
#        [8. , 8. , 7. ]])
Comment

PREVIOUS NEXT
Code Example
Python :: python random.sample 
Python :: remove last digit from number python 
Python :: join function python 
Python :: python reply to email 
Python :: django change foreign key 
Python :: numpy arange 
Python :: Send Fetch Post With Data Using Body 
Python :: protected class python 
Python :: how to add array and array python 
Python :: how to delete a column in pandas dataframe 
Python :: python referenced before assignment in function 
Python :: append to an array in 1st place python 
Python :: drf serializer 
Python :: load list from file python 
Python :: deleting a tuple in python 
Python :: python cat 
Python :: how to make a random number generator in python 
Python :: draw bipartite graph networkx 
Python :: pandas dataframe check for values more then a number 
Python :: literal_eval in python 
Python :: python int in list 
Python :: django model functions 
Python :: python typing 
Python :: python separate strings into characters 
Python :: one-hot encode categorical variables standardize numerical variables 
Python :: fast api template syntax 
Python :: net way to print 2d array 
Python :: python singleton class 
Python :: what does the combinations itertools in python do 
Python :: numpy.where 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =