def _prepare(self, data): data = get_single_column(data) if self.only_if_categorical and not utils.is_categorical(data): return None levels = self.levels if not levels: levels = sorted(set(data)) return levels
def _apply(self, data, fitted_feature): factors = fitted_feature.prepped_data data = get_single_column(data) d = DataFrame(index=data.index) if self.include_all: facts = list(factors) else: facts = list(factors)[:-1] for f in facts: d['%s-%s'%(f, data.name)] = data.map(lambda x: int(x == f)) return d
def _prepare(self, data): try: data = get_single_column(data) except ValueError: return None if self.only_if_categorical and not utils.is_categorical(data): return None levels = self.levels if not levels: levels = sorted(set(data)) return levels
def _apply(self, data, fitted_feature): factors = fitted_feature.prepped_data if factors is None: return data data = get_single_column(data) d = DataFrame(index=data.index) if self.include_all: facts = list(factors) else: facts = list(factors)[:-1] for f in facts: d['%s-%s' % (f, data.name)] = data.map(lambda x: int(x == f)) return d
def _prepare(self, data): levels = self.levels if not levels: levels = sorted(set(get_single_column(data))) return levels
def _prepare(self, data): levels = self.levels if not levels: levels = set(get_single_column(data)) levels = zip(levels, range(len(levels))) return levels
def build_target_safe(target, data, prep_index=None, train_index=None): y, ff = target.build(data, prep_index, train_index) return get_single_column(y), ff
def apply_target_safe(target, data, fitted_feature): y = target.apply(data, fitted_feature) return get_single_column(y)