Example #1
0
    def load(file, data=None):
        import pickle
        dico = pickle.load(open(file, 'rb'))

        normalizer = None
        neighborhood_calculator = NeighborhoodFactory.build(
            dico['neighborhood'])

        sm = SOMMap(data,
                    neighborhood_calculator,
                    normalizer,
                    mapsize=dico['mapsize'],
                    mask=dico['mask'],
                    mapshape=dico['mapshape'],
                    lattice=dico['lattice'],
                    initialization=dico['initialization'],
                    training=dico['training'],
                    radius_train=dico['radius_train'],
                    name=dico['name'],
                    component_names=dico['comp_names'],
                    components_to_plot=None)
        if dico['normalization']:
            #normalizer = NormalizerFactory.build(dico['normalization'])
            sm._normalizer = dico['normalization']
        #sm._normalizer.params= dico['norm_params']
        #sm._normalizer.normalized = True if dico['normalization'] is not None else False
        sm.codebook.matrix = dico['codebook']
        sm.codebook.initialized = dico['codebookinitialized']
        sm._dim = dico['dim']

        return sm
Example #2
0
    def build(sData,
              mapsize=None,
              mask=None,
              mapshape='planar',
              lattice='rect',
              normalization='var',
              initialization='pca',
              neighborhood='gaussian',
              training='batch',
              radius_train='linear',
              name='sompyMap',
              components_to_plot=None):
        """
        :param data: data to be clustered, represented as a matrix of n rows,
            as inputs and m cols as input features
        :param neighborhood: neighborhood object calculator.  Options are:
            - gaussian
            - bubble
            - manhattan (not implemented yet)
            - cut_gaussian (not implemented yet)
            - epanechicov (not implemented yet)

        :param normalization: normalizer object calculator. Options are:
            - var

        :param mapsize: tuple/list defining the dimensions of the som.
            If single number is provided is considered as the number of nodes.
        :param mask: mask
        :param mapshape: shape of the som. Options are:
            - planar
            - toroid (not implemented yet)
            - cylinder (not implemented yet)

        :param lattice: type of lattice. Options are:
            - rect
            - hexa

        :param initialization: method to be used for initialization of the som.
            Options are:
            - pca
            - random

        :param name: name used to identify the som
        :param training: Training mode (seq, batch)
        """
        if normalization and type(normalization) == str:
            normalizer = []
            for i in range(len(sData._data[0])):
                normalizer.append(NormalizerFactory.build(normalization))
        elif normalization and type(normalization) == list:
            normalizer = []
            for i in range(len(sData._data[0])):
                normalizer.append(NormalizerFactory.build(normalization[i]))
        else:
            normalizer = sData._normalizer
        neighborhood_calculator = NeighborhoodFactory.build(neighborhood)
        return SOMMap(sData._data, neighborhood_calculator, normalizer,
                      mapsize, mask, mapshape, lattice, initialization,
                      training, radius_train, name, sData.component_names,
                      components_to_plot, sData.isNormalized)
Example #3
0
    def build(data,
              mapsize=None,
              mask=None,
              mapshape='planar',
              lattice='rect',
              normalization='var',
              initialization='pca',
              neighborhood='gaussian',
              training='batch',
              name='sompy',
              component_names=None):
        """
        :param data: data to be clustered, represented as a matrix of n rows,
            as inputs and m cols as input features
        :param neighborhood: neighborhood object calculator.  Options are:
            - gaussian
            - bubble
            - manhattan (not implemented yet)
            - cut_gaussian (not implemented yet)
            - epanechicov (not implemented yet)

        :param normalization: normalizer object calculator. Options are:
            - var

        :param mapsize: tuple/list defining the dimensions of the som.
            If single number is provided is considered as the number of nodes.
        :param mask: mask
        :param mapshape: shape of the som. Options are:
            - planar
            - toroid (not implemented yet)
            - cylinder (not implemented yet)

        :param lattice: type of lattice. Options are:
            - rect
            - hexa (not implemented yet)

        :param initialization: method to be used for initialization of the som.
            Options are:
            - pca
            - random

        :param name: name used to identify the som
        :param training: Training mode (seq, batch)
        """
        if normalization:
            normalizer = NormalizatorFactory.build(normalization)
        else:
            normalizer = None
        neighborhood_calculator = NeighborhoodFactory.build(neighborhood)

        return SOM(data, neighborhood_calculator, normalizer, mapsize, mask,
                   mapshape, lattice, initialization, training, name, component_names)
Example #4
0
    def build(data,
              mapsize,
              mask=None,
              mapshape='planar',
              lattice='rect',
              normalization='var',
              initialization='pca',
              neighborhood='gaussian',
              training='batch',
              name='sompy'):
        """
        :param data: data to be clustered, represented as a matrix of n rows, as inputs and m cols as input features
        :param neighborhood: neighborhood object calculator.     Options are:
            - gaussian
            - bubble
            - manhattan (not implemented yet)
            - cut_gaussian (not implemented yet)
            - epanechicov (not implemented yet)

        :param normalization: normalizer object calculator. Options are:
            - var

        :param mapsize: tuple/list defining the dimensions of the som. If single number is provided is considered as the number of nodes.
        :param mask: mask
        :param mapshape: shape of the som. Options are:
            - planar
            - toroid (not implemented yet)
            - cylinder (not implemented yet)

        :param lattice: type of lattice. Options are:
            - rect
            - hexa (not implemented yet)

        :param initialization: method to be used for initialization of the som. Options are:
            - pca
            - random

        :param name: name used to identify the som
        :param training: Training mode (seq, batch)
        """
        normalizer = NormalizatorFactory.build(normalization) if normalization else None
        neighborhood_calculator = NeighborhoodFactory.build(neighborhood)

        return SOM(data, neighborhood_calculator, normalizer, mapsize, mask, mapshape, lattice, initialization, training, name)