Created
May 22, 2020 17:06
-
-
Save pr2tik1/5491a9c4dc36be49ae017e23197a428c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Imputation(self, var ,stats=False): | |
''' | |
Function to Impute data using sklearn Imputer | |
Input : Dataframe, variable(continuous/categorical) | |
Output : None | |
''' | |
if var==self.continuous: | |
imputer= SimpleImputer(strategy='median') | |
if var==self.categorical: | |
imputer = SimpleImputer(strategy='most_frequent') | |
else: | |
print("Imputation over continuous and categorical only") | |
imputer.fit(self.data[var]) | |
self.data[var] = imputer.transform(self.data[var]) | |
print("Imputer Fitted and Transformed!") | |
if stats==True: | |
imputer.statistics_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment