def fit(self, X, y=None, **kwargs):
<EOL>X = util.convert_input(X)<EOL>self._dim = X.shape[<NUM_LIT:1>]<EOL>if self.cols is None:<EOL><INDENT>self.cols = util.get_obj_cols(X)<EOL><DEDENT>else:<EOL><INDENT>self.cols = util.convert_cols_to_list(self.cols)<EOL><DEDENT>if self.handle_missing == '<STR_LIT:error>':<EOL><INDENT>if X[self.cols].isnull().any().bool():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>self.ordinal_encoder = OrdinalEncoder(<EOL>verbose=self.verbose,<EOL>cols=self.cols,<EOL>handle_unknown='<STR_LIT:value>',<EOL>handle_missing='<STR_LIT:value>'<EOL>)<EOL>self.ordinal_encoder = self.ordinal_encoder.fit(X)<EOL>ordinal_mapping = self.ordinal_encoder.category_mapping<EOL>mappings_out = []<EOL>for switch in ordinal_mapping:<EOL><INDENT>values = switch.get('<STR_LIT>')<EOL>col = switch.get('<STR_LIT>')<EOL>column_mapping = self.fit_polynomial_coding(col, values, self.handle_missing, self.handle_unknown)<EOL>mappings_out.append({'<STR_LIT>': switch.get('<STR_LIT>'), '<STR_LIT>': column_mapping, })<EOL><DEDENT>self.mapping = mappings_out<EOL>X_temp = self.transform(X, override_return_df=True)<EOL>self.feature_names = X_temp.columns.tolist()<EOL>if self.drop_invariant:<EOL><INDENT>self.drop_cols = []<EOL>generated_cols = util.get_generated_cols(X, X_temp, self.cols)<EOL>self.drop_cols = [x for x in generated_cols if X_temp[x].var() <= <NUM_LIT>]<EOL>try:<EOL><INDENT>[self.feature_names.remove(x) for x in self.drop_cols]<EOL><DEDENT>except KeyError as e:<EOL><INDENT>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>"<EOL>"<STR_LIT>".format(e))<EOL><DEDENT><DEDENT><DEDENT>return self<EOL>
Fit encoder according to X and y.

        Parameters
        ----------

        X : array-like, shape = [n_samples, n_features]
            Training vectors, where n_samples is the number of samples
            and n_features is the number of features.
        y : array-like, shape = [n_samples]
            Target values.

        Returns
        -------

        self : encoder
            Returns self.