(self, data, replace_method, replace_value=None, output_format=None,
                      col_replace_method=None)
return transform_data, cols_transform_value
def _transform_nan(instance):
            feature_shape = instance.features.shape[0]
            new_features = copy.deepcopy(instance.features)

            for i in range(feature_shape):
                if np.isnan(instance.features[i]):
                    new_features[i] = NoneType()
            new_instance = copy.deepcopy(instance)
            new_instance.features = new_features
            return new_instance
def _transform_nan(instance):
            feature_shape = instance.features.shape[0]
            new_features = copy.deepcopy(instance.features)
def _transform_nan ( instance ) : feature_shape = instance . features . shape [ 0 ] new_features = copy . deepcopy ( instance . features )
def __fit_replace(self, data, replace_method, replace_value=None, output_format=None,
                      col_replace_method=None):
        replace_method_per_col, skip_cols = self.__get_cols_transform_method(data, replace_method, col_replace_method)

        """
        def _transform_nan(instance):
            feature_shape = instance.features.shape[0]
            new_features = copy.deepcopy(instance.features)

            for i in range(feature_shape):
                if np.isnan(instance.features[i]):
                    new_features[i] = NoneType()
            new_instance = copy.deepcopy(instance)
            new_instance.features = new_features
            return new_instance
        """
        def _transform_nan(instance):
            feature_shape = instance.features.shape[0]
            new_features = []

            for i in range(feature_shape):
                if instance.features[i] != instance.features[i]:
                    new_features.append(NoneType())
                else:
                    new_features.append(instance.features[i])
            new_instance = copy.deepcopy(instance)
            new_instance.features = np.array(new_features)
            return new_instance
        schema = data.schema
        if isinstance(data.first()[1], Instance):
            data = data.mapValues(lambda v: _transform_nan(v))
            data.schema = schema
        cols_transform_value = self.__get_cols_transform_value(data, replace_method_per_col,
                                                               replace_value=replace_value)
        self.skip_cols = skip_cols
        skip_cols = [get_header(data).index(v) for v in skip_cols]
        if output_format is not None:
            f = functools.partial(Imputer.replace_missing_value_with_cols_transform_value_format,
                                  transform_list=cols_transform_value, missing_value_list=self.abnormal_value_list,
                                  output_format=output_format, skip_cols=set(skip_cols))
        else:
            f = functools.partial(Imputer.replace_missing_value_with_cols_transform_value,
                                  transform_list=cols_transform_value, missing_value_list=self.abnormal_value_list,
                                  skip_cols=set(skip_cols))

        transform_data = data.mapValues(f)
        self.cols_replace_method = replace_method_per_col
        LOGGER.info(
            "finish replace missing value with cols transform value, replace method is {}".format(replace_method))
        return transform_data, cols_transform_value
def __fit_replace ( self , data , replace_method , replace_value = None , output_format = None , col_replace_method = None ) : replace_method_per_col , skip_cols = self . __get_cols_transform_method ( data , replace_method , col_replace_method ) def _transform_nan ( instance ) : feature_shape = instance . features . shape [ 0 ] new_features = [ ] for i in range ( feature_shape ) : if instance . features [ i ] != instance . features [ i ] : new_features . append ( NoneType ( ) ) else : new_features . append ( instance . features [ i ] ) new_instance = copy . deepcopy ( instance ) new_instance . features = np . array ( new_features ) return new_instance schema = data . schema if isinstance ( data . first ( ) [ 1 ] , Instance ) : data = data . mapValues ( lambda v : _transform_nan ( v ) ) data . schema = schema cols_transform_value = self . __get_cols_transform_value ( data , replace_method_per_col , replace_value = replace_value ) self . skip_cols = skip_cols skip_cols = [ get_header ( data ) . index ( v ) for v in skip_cols ] if output_format is not None : f = functools . partial ( Imputer . replace_missing_value_with_cols_transform_value_format , transform_list = cols_transform_value , missing_value_list = self . abnormal_value_list , output_format = output_format , skip_cols = set ( skip_cols ) ) else : f = functools . partial ( Imputer . replace_missing_value_with_cols_transform_value , transform_list = cols_transform_value , missing_value_list = self . abnormal_value_list , skip_cols = set ( skip_cols ) ) transform_data = data . mapValues ( f ) self . cols_replace_method = replace_method_per_col LOGGER . info ( "finish replace missing value with cols transform value, replace method is {}" . format ( replace_method ) ) return transform_data , cols_transform_value