示例#1
0
 def test_train_learning_rate_less_than_zero_should_raise_value_error(self):
     data = pd.read_csv('../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5)
     with self.assertRaises(ValueError):
         som.train(data, alpha=-0.01)
     self.assertFalse(som.trained)
     self.assertIsNone(som.codebook)
示例#2
0
 def test_hexagonal(self):
     data = pd.read_csv('../../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5, "hexagonal")
     som.train(data)
     qe_m(som)
     mqe_m(som)
     mqe(som)
     mmqe(som)
示例#3
0
 def test_rectangular(self):
     data = pd.read_csv('../../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5)
     som.train(data)
     qe_m(som)
     mqe_m(som)
     mqe(som)
     mmqe(som)
示例#4
0
 def test_train_hexagonal(self):
     data = pd.read_csv('../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5, "hexagonal")
     som.train(data)
     self.assertTrue(som.trained)
     self.assertIsNotNone(som.codebook)
     self.assertIsNotNone(som.bmu_indices)
     self.assertIsNotNone(som.bmu_distances)
     self.assertIsNotNone(som.get_first_bmus())
     self.assertIsNotNone(som.get_second_bmus())
示例#5
0
 def test_rectangular(self):
     data = pd.read_csv('../../../data/test_data.csv').drop(['Class'],
                                                            axis=1)
     som = StandardSOM((50, 50), 5)
     som.train(data)
     self.assertTrue(som.trained)
     self.assertIsNotNone(som.codebook)
     self.assertIsNotNone(som.bmu_indices)
     self.assertIsNotNone(som.bmu_distances)
     self.assertIsNotNone(som.get_first_bmus())
     self.assertIsNotNone(som.get_second_bmus())
     topographic_error(som)
示例#6
0
 def test_hexagonal(self):
     data = pd.read_csv('../../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5, "hexagonal")
     som.train(data)
     topographic_error(som)
示例#7
0
 def test_train_iterations_less_than_zero_should_raise_value_error(self):
     data = pd.read_csv('../data/test_data.csv').drop(['Class'], axis=1)
     som = StandardSOM((50, 50), 5)
     with self.assertRaises(ValueError):
         som.train(data, iterations=-1)
示例#8
0
 def test_train_data_none_should_raise_value_error(self):
     som = StandardSOM((50, 50), 5)
     with self.assertRaises(ValueError):
         som.train(None)