## How to impute missing class labels in Python
def Kickstarter_Example_27():
print()
print(format('How to impute missing class labels in Python', '*^82'))
import warnings
warnings.filterwarnings("ignore")
# Load libraries
import numpy as np
from sklearn.preprocessing import Imputer
# Create Feature Matrix With Missing Values
X = np.array([[2, 2.10, 1.45],
[1, 1.18, 1.33],
[2, 1.22, 1.27],
[0, -0.21, -1.19],
[np.nan, 0.87, 1.31],
[np.nan, -0.67, -0.22]])
# Create Imputer object
imputer = Imputer(strategy='most_frequent', axis=0)
# Fill missing values with most frequent class
print(); print(X)
print(); print(imputer.fit_transform(X))
Kickstarter_Example_27()