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)
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)
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)
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())
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)
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)
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)
def test_train_data_none_should_raise_value_error(self): som = StandardSOM((50, 50), 5) with self.assertRaises(ValueError): som.train(None)