3 @brief Cluster analysis algorithm: TTSAS (Two-Threshold Sequential Algorithmic Scheme). 4 @details Implementation based on paper @cite book::pattern_recognition::2009. 6 @authors Andrei Novikov (pyclustering@yandex.ru) 8 @copyright GNU Public License 10 @cond GNU_PUBLIC_LICENSE 11 PyClustering is free software: you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation, either version 3 of the License, or 14 (at your option) any later version. 16 PyClustering is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 21 You should have received a copy of the GNU General Public License 22 along with this program. If not, see <http://www.gnu.org/licenses/>. 28 from pyclustering.core.ttsas_wrapper
import ttsas
as ttsas_wrapper
29 from pyclustering.core.metric_wrapper
import metric_wrapper
36 @brief Class represents TTSAS (Two-Threshold Sequential Algorithmic Scheme). 37 @details Clustering results of BSAS and MBSAS are strongly dependent on the order in which the points in data. 38 TTSAS helps to overcome this shortcoming by using two threshold parameters. The first - if the distance 39 to the nearest cluster is less than the first threshold then point is assigned to the cluster. The 40 second - if distance to the nearest cluster is greater than the second threshold then new cluster is 43 Code example of TTSAS usage: 45 # Read data sample from 'Simple03.data'. 46 sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE3); 48 # Prepare algorithm's parameters. 52 # Create instance of TTSAS algorithm. 53 ttsas_instance = ttsas(sample, max_clusters, threshold); 54 ttsas_instance.process(); 56 # Get clustering results. 57 clusters = ttsas_instance.get_clusters(); 58 representatives = ttsas_instance.get_representatives(); 60 # Display results using BSAS visualizer. 61 bsas_visualizer.show_clusters(sample, clusters, representatives); 64 @see pyclustering.cluster.bsas, pyclustering.cluster.mbsas 68 def __init__(self, data, threshold1, threshold2, ccore, **kwargs):
70 @brief Creates TTSAS algorithm. 72 @param[in] data (list): Input data that is presented as list of points (objects), each point should be represented by list or tuple. 73 @param[in] threshold1: Dissimilarity level (distance) between point and its closest cluster, if the distance is 74 less than 'threshold1' value then point is assigned to the cluster. 75 @param[in] threshold2: Dissimilarity level (distance) between point and its closest cluster, if the distance is 76 greater than 'threshold2' value then point is considered as a new cluster. 77 @param[in] ccore (bool): If True than DLL CCORE (C++ solution) will be used for solving. 78 @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'metric'). 80 <b>Keyword Args:</b><br> 81 - metric (distance_metric): Metric that is used for distance calculation between two points. 89 super().
__init__(data, len(data), threshold1, ccore, **kwargs);
94 @brief Performs cluster analysis in line with rules of BSAS algorithm. 96 @remark Results of clustering can be obtained using corresponding get methods. 99 @see get_representatives() 109 def __process_by_ccore(self):
110 ccore_metric = metric_wrapper.create_instance(self.
_metric);
114 def __prcess_by_python(self):
123 def __process_objects(self, changes):
130 for i
in range(index_point, len(self.
_data)):
135 def __process_skipped_object(self, index_point):
136 point = self.
_data[index_point];
146 def __append_to_cluster(self, index_cluster, index_point, point):
147 self.
_clusters[index_cluster].append(index_point);
154 def __allocate_cluster(self, index_point, point):
Class represents BSAS clustering algorithm - basic sequential algorithmic scheme. ...
Cluster analysis algorithm: BSAS (Basic Sequential Algorithmic Scheme).
def __process_skipped_object(self, index_point)
Class represents TTSAS (Two-Threshold Sequential Algorithmic Scheme).
def __allocate_cluster(self, index_point, point)
def __init__(self, data, threshold1, threshold2, ccore, kwargs)
Creates TTSAS algorithm.
def _find_nearest_cluster(self, point)
Find nearest cluster to the specified point.
def __prcess_by_python(self)
def __process_by_ccore(self)
def __append_to_cluster(self, index_cluster, index_point, point)
def _update_representative(self, index_cluster, point)
Update cluster representative in line with new cluster size and added point to it.
def process(self)
Performs cluster analysis in line with rules of BSAS algorithm.
def __process_objects(self, changes)