Beispiel #1
0
 def test_fit(self):
     print('test fit')
     mgs, poolayer, concat_layer, auto_cascade = self._init()
     model = Graph()
     model.add(mgs)
     model.add(poolayer)
     model.add(concat_layer)
     model.add(auto_cascade)
     model.fit(self.x_train, self.y_train)
Beispiel #2
0
 def test_fit_transform_full(self):
     print("test fit_transform_full")
     mgs, poolayer, concat_layer, auto_cascade = self._init()
     model = Graph()
     model.add(mgs)
     model.add(poolayer)
     model.add(concat_layer)
     model.add(auto_cascade)
     model.fit_transform(self.x_train, self.y_train, self.x_test,
                         self.y_test)
Beispiel #3
0
 def test_graph_transform(self):
     print('test graph transform')
     gc, agc = self._init()
     agc.keep_in_mem = True
     model = Graph()
     model.add(agc)
     model.fit(self.x_train, self.y_train)
     model.transform(self.x_test)
Beispiel #4
0
 def test_graph_fit_evaluate(self):
     print('test fit and evaluate')
     gc, agc = self._init()
     agc.keep_in_mem = True
     model = Graph()
     model.add(agc)
     model.fit(self.x_train, self.y_train)
     model.evaluate(self.x_test, self.y_test)
Beispiel #5
0
print('x_test.shape: {}'.format(x_test.shape))

est_configs = [
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig()
]

data_save_dir = osp.join(get_data_save_base(), 'uci_yeast')
model_save_dir = osp.join(get_model_save_base(), 'uci_yeast')

auto_cascade = AutoGrowingCascadeLayer(est_configs=est_configs,
                                       early_stopping_rounds=4,
                                       n_classes=10,
                                       data_save_dir=data_save_dir,
                                       model_save_dir=model_save_dir,
                                       distribute=False,
                                       seed=0)

model = Graph()
model.add(auto_cascade)
model.fit_transform(x_train, y_train, x_test, y_test)

print("time cost: {}".format(time.time() - start_time))

Beispiel #6
0
rf2 = RandomForestConfig(n_folds=3, min_samples_leaf=10)

est_for_windows = [[rf1, rf2], [rf1, rf2], [rf1, rf2]]

mgs = MultiGrainScanLayer(windows=windows,
                          est_for_windows=est_for_windows,
                          n_class=6)

pools = [[MeanPooling(), MeanPooling()], [MeanPooling(),
                                          MeanPooling()],
         [MeanPooling(), MeanPooling()]]

pool_layer = PoolingLayer(pools=pools)

concat_layer = ConcatLayer()

est_configs = Basic4x2()

auto_cascade = AutoGrowingCascadeLayer(est_configs=est_configs,
                                       early_stopping_rounds=4,
                                       n_classes=6,
                                       look_index_cycle=[[0, 1], [2, 3],
                                                         [4, 5]])

model = Graph()
model.add(mgs)
model.add(pool_layer)
# model.add(concat_layer)
model.add(auto_cascade)
model.fit_transform(x_train, y_train, x_test, y_test)
Beispiel #7
0
 def test_fit_evaluate(self):
     print("test fit and evaluate")
     mgs, poolayer, concat_layer, auto_cascade = self._init()
     mgs.keep_in_mem = True
     auto_cascade.keep_in_mem = True
     model = Graph()
     model.add(mgs)
     model.add(poolayer)
     model.add(concat_layer)
     model.add(auto_cascade)
     model.fit(self.x_train, self.y_train)
     model.evaluate(self.x_test, self.y_test)
Beispiel #8
0
 def test_transform(self):
     print("test transform")
     mgs, poolayer, concat_layer, auto_cascade = self._init()
     mgs.keep_in_mem = True
     auto_cascade.keep_in_mem = True
     model = Graph()
     model.add(mgs)
     model.add(poolayer)
     model.add(concat_layer)
     model.add(auto_cascade)
     model.fit(self.x_train, self.y_train)
     model.transform(self.x_test)
Beispiel #9
0
 def test_graph_summary(self):
     model = Graph()
     model.add(self.mgs, self.poolayer, self.concat_layer, self.auto_cascade)
     model.summary()
Beispiel #10
0
 def test_uci_graph(self):
     print('test uci_graph')
     gc, agc = self._init()
     model = Graph()
     model.add(agc)
     model.fit_transform(self.x_train, self.y_train, self.x_test, self.y_test)