Example #1
0
 def test_umatrix_scale(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     som._weights = np.tile(np.arange(som.n_features), (som.n_units, 1))
     som._weights[:, -1] = np.arange(som.n_units)
     um = som.umatrix(scale=True, norm=False)
     self.assertEqual(um[0, 0], um[-1, -1])
     self.assertEqual(um[0, -1], um[-1, 0])
Example #2
0
 def test_umatrix_norm(self, dims: SomDim) -> None:
     data = np.random.rand(100, dims[2])
     som = SomBase(dims, 10, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     som._weights = som.init_weights(data, som.shape)
     um = som.umatrix(norm=True)
     self.assertEqual(um.max(), 1.0)
Example #3
0
 def test_match(self, dims: SomDim) -> None:
     data = np.random.rand(100, dims[2])
     som = SomBase(dims, 10, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     som._weights = som.init_weights(data, som.shape)
     self.assertIsInstance(som.match(data), np.ndarray)
Example #4
0
 def test_weights(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     self.assertIsNone(som.weights)
Example #5
0
 def test_grid(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     self.assertIsInstance(som.grid, SomGrid)
Example #6
0
 def test_shape(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     self.assertEqual(som.shape, (dims[0], dims[1]))
Example #7
0
 def test_n_units(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     self.assertEqual(som.n_units, dims[0]*dims[1])
Example #8
0
 def test_dw(self, dims: SomDim) -> None:
     som = SomBase(dims, 100, 0.1, 10, 'gaussian', 'rnd', 'euclidean')
     self.assertEqual(som.dw, dims[2])