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

Before Change


    def _score(self, X, y):
        for switch in self.mapping:
            // Get column name (can be anything: str, number,...)
            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

After Change


    def _score(self, X, y):
        for col in self.cols:
            // Score the column
            X[col] = X[col].map(self.mapping[col])

            // Replace missing values only in the computed columns
            if self.impute_missing:
                if self.handle_unknown == "impute":
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

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: scikit-learn-contrib/categorical-encoding
Commit Name: b5034279b48ae96ffdd4714f96e0f62b0f4807fc
Time: 2018-10-26
Author: jcastaldo08@gmail.com
File Name: category_encoders/ordinal.py
Class Name: OrdinalEncoder
Method Name: ordinal_encoding


Project Name: soft-matter/trackpy
Commit Name: cc410f68b6c1d1417322ec02e22ea7713ca0bc48
Time: 2020-03-18
Author: ruben@lighthacking.nl
File Name: trackpy/locate_functions/brightfield_ring.py
Class Name:
Method Name: locate_brightfield_ring