3 @brief Cluster analysis algorithm: SOM-SC (Self-Organized Feature Map for Simple Clustering) 4 @details There is no paper on which implementation is based. Algorithm SOM-SC is adaptation of SOM for cluster analysis in simple way. 5 Basic idea: amount of cluster that should be allocated is defines amount of neurons in the self-organized map. SOM-SC can be 6 considered as neural network implementation of K-Means algorithm. 7 Implementation based on paper @cite article::nnet::som::1. 9 @authors Andrei Novikov (pyclustering@yandex.ru) 11 @copyright GNU Public License 13 @cond GNU_PUBLIC_LICENSE 14 PyClustering is free software: you can redistribute it and/or modify 15 it under the terms of the GNU General Public License as published by 16 the Free Software Foundation, either version 3 of the License, or 17 (at your option) any later version. 19 PyClustering is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 24 You should have received a copy of the GNU General Public License 25 along with this program. If not, see <http://www.gnu.org/licenses/>. 39 @brief Class represents simple clustering algorithm based on self-organized feature map. 40 @details This algorithm uses amount of clusters that should be allocated as a size of SOM map. Captured objects by neurons are clusters. 41 Algorithm is able to process data with Gaussian distribution that has spherical forms. 45 from pyclustering.cluster import cluster_visualizer 46 from pyclustering.cluster.somsc import somsc 47 from pyclustering.samples.definitions import FCPS_SAMPLES 48 from pyclustering.utils import read_sample 50 # Load list of points for cluster analysis 51 sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS) 53 # Create instance of SOM-SC algorithm to allocated two clusters 54 somsc_instance = somsc(sample, 2) 56 # Run cluster analysis and obtain results 57 somsc_instance.process() 58 clusters = somsc_instance.get_clusters() 60 # Visualize clustering results. 61 visualizer = cluster_visualizer() 62 visualizer.append_clusters(clusters, sample) 68 def __init__(self, data, amount_clusters, epouch=100, ccore=True):
70 @brief Creates SOM-SC (Self Organized Map for Simple Clustering) algorithm for clustering analysis. 72 @param[in] data (list): List of points that are used for processing. 73 @param[in] amount_clusters (uint): Amount of clusters that should be allocated. 74 @param[in] epouch (uint): Number of epochs for training of SOM. 75 @param[in] ccore (bool): If it is True then CCORE implementation will be used for clustering analysis. 91 @brief Performs cluster analysis by competition between neurons of SOM. 93 @return (somsc) Returns itself (SOM Simple Clustering instance). 106 @brief Returns list of allocated clusters, each cluster contains indexes of objects in list of data. 117 @brief Returns clustering result representation type that indicate how clusters are encoded. 119 @return (type_encoding) Clustering result representation. 125 return type_encoding.CLUSTER_INDEX_LIST_SEPARATION
128 def __verify_arguments(self):
130 @brief Verify input parameters for the algorithm and throw exception in case of incorrectness. 134 raise ValueError(
"Input data is empty (size: '%d')." % len(self.
__data_pointer))
137 raise ValueError(
"Amount of clusters (current value: '%d') should be greater than 0." %
141 raise ValueError(
"Amount of epouch (current value: '%d') should be greater or equal to 0." %
def __init__(self, data, amount_clusters, epouch=100, ccore=True)
Creates SOM-SC (Self Organized Map for Simple Clustering) algorithm for clustering analysis...
def get_cluster_encoding(self)
Returns clustering result representation type that indicate how clusters are encoded.
Module for representing clustering results.
def __verify_arguments(self)
Verify input parameters for the algorithm and throw exception in case of incorrectness.
def get_clusters(self)
Returns list of allocated clusters, each cluster contains indexes of objects in list of data...
Class represents simple clustering algorithm based on self-organized feature map. ...
def process(self)
Performs cluster analysis by competition between neurons of SOM.
Neural Network: Self-Organized Feature Map.
Represents self-organized feature map (SOM).