Last active
January 15, 2018 09:33
-
-
Save compmonks/efc6ac8548232efe4c99b1ac6b6c1d48 to your computer and use it in GitHub Desktop.
SOM init with a previous codebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SOM(object): | |
def __init__(self, | |
data, | |
neighborhood, | |
prev_codebook_matrix=None, # initialization with previous codebook matrix | |
normalizer=None, | |
mapsize=None, | |
mask=None, | |
mapshape='planar', | |
lattice='rect', | |
initialization='pca', | |
training='batch', | |
name='sompy', | |
component_names=None): | |
self._data = normalizer.normalize(data) if normalizer else data | |
self._normalizer = normalizer | |
self._dim = data.shape[1] | |
self._dlen = data.shape[0] | |
self._dlabel = None | |
self._bmu = None | |
self.name = name | |
self.data_raw = data | |
self.neighborhood = neighborhood | |
self.mapshape = mapshape | |
self.initialization = initialization | |
self.mask = mask or np.ones([1, self._dim]) | |
mapsize = self.calculate_map_size(lattice) if not mapsize else mapsize | |
############################################################################# | |
# self.codebook = Codebook(mapsize, lattice) | |
if prev_codebook_matrix == None: | |
self.codebook = Codebook(mapsize, lattice) | |
else: | |
self.codebook = Codebook(mapsize, lattice) | |
self.codebook.matrix = prev_codebook_matrix # initialization with previous codebook matrix | |
############################################################################# | |
self.training = training | |
self._component_names = self.build_component_names() if component_names is None else [component_names] | |
self._distance_matrix = self.calculate_map_dist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment