def fit(self, X, y, **kwargs):
<EOL>X = util.convert_input(X)<EOL>y = util.convert_input_vector(y, X.index).astype(float)<EOL>if X.shape[<NUM_LIT:0>] != y.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError("<STR_LIT>" + str(X.shape[<NUM_LIT:0>]) + "<STR_LIT>" + str(y.shape[<NUM_LIT:0>]) + "<STR_LIT:.>")<EOL><DEDENT>self._dim = X.shape[<NUM_LIT:1>]<EOL>if self.use_default_cols:<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>categories = self.fit_leave_one_out(<EOL>X, y,<EOL>cols=self.cols<EOL>)<EOL>self.mapping = categories<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.