コード例 #1
0
    def get_feature_names_out(self, input_features: List[str] = None):
        from sklearn.utils.validation import _check_feature_names_in
        names = _check_feature_names_in(self, input_features)

        if self.add_indicator:
            columns = [
                f'missing_{input_features[idx]}'
                for idx in self.estimator_.indicator_.features_
            ]
            names = np.append(names, columns)

        return names
コード例 #2
0
def monkey_patch_get_feature_names_out():
    # Some transformers do not implement get_feature_names_out, monkey-patch it in
    if 'get_feature_names_out_patched' not in globals():
        func = lambda est, input_features=None: _check_feature_names_in(
            est, input_features)
        SimpleImputer.get_feature_names_out = func
        OrdinalEncoder.get_feature_names_out = func

        # add marker to globals to prevent second execution
        # noinspection PyGlobalUndefined
        global get_feature_names_out_patched
        get_feature_names_out_patched = True
コード例 #3
0
    def get_feature_names_out(self, input_features: List[str] = None):
        from sklearn.utils.validation import _check_feature_names_in

        names = _check_feature_names_in(self, input_features)
        if self.add_indicator:
            imp = self.estimator_.transformer_list[0][1]
            mis = self.estimator_.transformer_list[1][1]
            names = np.append(names[imp._columns[0]], names[imp._columns[1]])
            names = np.append(names, mis.get_feature_names_out())
        else:
            names = np.append(names[self.estimator_._columns[0]], names[self.estimator_._columns[1]])

        return names
コード例 #4
0
 def get_feature_names_out(self, input_features: List[str] = None):
     return _check_feature_names_in(self, input_features)
コード例 #5
0
 def get_feature_names_out(self, input_features: List[str] = None):
     from sklearn.utils.validation import _check_feature_names_in
     return _check_feature_names_in(self, input_features)