Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
 def _prepare(self, data):
     levels = self.levels
     if not levels:
         levels = sorted(set(get_single_column(data)))
     return levels
Exemple #6
0
 def _prepare(self, data):
     levels = self.levels
     if not levels:
         levels = set(get_single_column(data))
         levels = zip(levels, range(len(levels)))
     return levels
Exemple #7
0
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
Exemple #8
0
def apply_target_safe(target, data, fitted_feature):
    y = target.apply(data, fitted_feature)
    return get_single_column(y)
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
Exemple #10
0
def apply_target_safe(target, data, fitted_feature):
    y = target.apply(data, fitted_feature)
    return get_single_column(y)
Exemple #11
0
 def _prepare(self, data):
     levels = self.levels
     if not levels:
         levels = set(get_single_column(data))
         levels = zip(levels, range(len(levels)))
     return levels