Example #1
0
def feature_construction(data_matrix_original, selectors):
    from eden.selector import CompositeSelector
    selector = CompositeSelector(selectors)
    from eden.selector import Projector
    projector = Projector(selector, metric='cosine')
    data_matrix = projector.fit_transform(data_matrix_original)
    return data_matrix
Example #2
0
 def randomize(self, data_matrix, amount=.5):
     random.seed(self.random_state)
     inclusion_threshold = random.uniform(amount, 1)
     selectors = []
     if random.random() > inclusion_threshold:
         selectors.append(
             SparseSelector(random_state=random.randint(1, 1e9)))
     if random.random() > inclusion_threshold:
         selectors.append(
             MaxVolSelector(random_state=random.randint(1, 1e9)))
     if random.random() > inclusion_threshold:
         selectors.append(
             QuickShiftSelector(random_state=random.randint(1, 1e9)))
     if random.random() > inclusion_threshold:
         selectors.append(
             DensitySelector(random_state=random.randint(1, 1e9)))
     if random.random() > inclusion_threshold:
         selectors.append(
             OnionSelector(random_state=random.randint(1, 1e9)))
     if not selectors:
         selectors.append(
             DensitySelector(random_state=random.randint(1, 1e9)))
         selectors.append(
             SparseSelector(random_state=random.randint(1, 1e9)))
     selector = CompositeSelector(selectors=selectors)
     selector.randomize(data_matrix, amount=amount)
     self.selectors = deepcopy(selector.selectors)
     self.metric = 'rbf'
     self.kwds = {'gamma': random.choice([10**x for x in range(-3, 3)])}
     if random.random() > inclusion_threshold:
         self.n_nearest_neighbors = random.randint(3, 20)
     else:
         self.n_nearest_neighbors = None
     self.n_links = random.randint(1, 5)
     self.random_state = self.random_state ^ random.randint(1, 1e9)