Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Titanic Machine Learning Project - Create an Imputer for String Categorical Columns

We will also need an imputer for the string categorical columns (the regular SimpleImputer does not work on those):


Now let's create a class named MostFrequentImputer for the imputer:

class << your code comes here >> (BaseEstimator, TransformerMixin):
    def fit(self, X, y=None):
        self.most_frequent_ = pd.Series([X[c].value_counts().index[0] for c in X],
        return self
    def transform(self, X, y=None):
        return X.fillna(self.most_frequent_)

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...