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( QuickShiftSelector(random_state=random.randint(1, 1e9))) if random.random() > inclusion_threshold: selectors.append( DecisionSurfaceSelector(random_state=random.randint(1, 1e9))) 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( 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( QuickShiftSelector(random_state=random.randint(1, 1e9))) self.selector = CompositeSelector(selectors=selectors) self.selector.randomize(data_matrix, amount=amount) self.metric = 'rbf' self.kwds = {'gamma': random.choice([10**x for x in range(-3, 3)])} self.random_state = self.random_state ^ random.randint(1, 1e9)
def make_selectors(opts): # compose selector list selectors = [] if 'QuickShiftSelector' in opts and opts['QuickShiftSelector'] is not None: from eden.selector import QuickShiftSelector selectors.append( QuickShiftSelector(n_instances=opts['QuickShiftSelector'])) if 'MaxVolSelector' in opts and opts['MaxVolSelector'] is not None: from eden.selector import MaxVolSelector selectors.append(MaxVolSelector(n_instances=opts['MaxVolSelector'])) if 'DensitySelector' in opts and opts['DensitySelector'] is not None: from eden.selector import DensitySelector selectors.append(DensitySelector(n_instances=opts['DensitySelector'])) if 'SparseSelector' in opts and opts['SparseSelector'] is not None: from eden.selector import SparseSelector selectors.append(SparseSelector(n_instances=opts['SparseSelector'])) if 'EqualizingSelector' in opts and opts['EqualizingSelector'] is not None: from sklearn.cluster import MiniBatchKMeans from eden.selector import EqualizingSelector n_clusters = opts['EqualizingSelector'] / 10 selectors.append( EqualizingSelector(n_instances=opts['EqualizingSelector'], clustering_algo=MiniBatchKMeans(n_clusters))) return selectors
def __init__(self, compiled=False, learning_rate=0.002, n_layers=1, n_features_hidden_factor=10, selectors=[QuickShiftSelector()], n_nearest_neighbors=10, n_links=1, layout='force', layout_prog='sfdp', layout_prog_args='-Goverlap=scale', n_eigenvectors=10, random_state=1, metric='rbf', **kwds): self.compiled = compiled self.learning_rate = learning_rate self.n_layers = n_layers self.n_features_hidden_factor = n_features_hidden_factor self.selectors = selectors self.n_nearest_neighbors = n_nearest_neighbors self.n_links = n_links self.layout = layout self.layout_prog = layout_prog self.layout_prog_args = layout_prog_args self.n_eigenvectors = n_eigenvectors self.metric = metric self.kwds = kwds self.random_state = random_state self.selected_instances_list = [] self.selected_instances_ids_list = []