970491cd9b3cb21b043c22b50b4d09f9dd2481a7,category_encoders/woe.py,WOEEncoder,_score,#WOEEncoder#Any#Any#,256

Before Change


            column = switch.get("col")

            // Score the column
            transformed_column = pd.Series([np.nan] * X.shape[0], name=column)
            for val in switch.get("woe"):
                transformed_column.loc[X[column] == val] = switch.get("woe")[val] // THIS LINE IS SLOW

            // Replace missing values only in the computed columns
            if self.impute_missing:
                if self.handle_unknown == "impute":
                    transformed_column.fillna(0, inplace=True)
                elif self.handle_unknown == "error":
                    missing = transformed_column.isnull()
                    if any(missing):
                        raise ValueError("Unexpected categories found in column %s" % switch.get("col"))

            // Randomization is meaningful only for training data -> we do it only if y is present
            if self.randomized and y is not None:
                random_state_generator = check_random_state(self.random_state)
                transformed_column = (transformed_column * random_state_generator.normal(1., self.sigma, transformed_column.shape[0]))

After Change


                if self.handle_unknown == "impute":
                    X[col].fillna(0, inplace=True)
                elif self.handle_unknown == "error":
                    if X[col].isnull().any():
                        raise ValueError("Unexpected categories found in column %s" % col)

            // Randomization is meaningful only for training data -> we do it only if y is present
            if self.randomized and y is not None:
                random_state_generator = check_random_state(self.random_state)
                X[col] = (X[col] * random_state_generator.normal(1., self.sigma, X[col].shape[0]))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: scikit-learn-contrib/categorical-encoding
Commit Name: 970491cd9b3cb21b043c22b50b4d09f9dd2481a7
Time: 2018-10-19
Author: jan@motl.us
File Name: category_encoders/woe.py
Class Name: WOEEncoder
Method Name: _score


Project Name: craffel/mir_eval
Commit Name: 3241912f4160c47e55e25f5812c8493d1f581fca
Time: 2014-04-23
Author: brm2132@columbia.edu
File Name: mir_eval/util.py
Class Name:
Method Name: validate_intervals


Project Name: bokeh/bokeh
Commit Name: 5f6b5d3851d0b719f401eafbfc569420405d1ef3
Time: 2016-08-16
Author: canavandl@gmail.com
File Name: bokeh/models/formatters.py
Class Name: FuncTickFormatter
Method Name: from_py_func