3 @brief Cluster generator. 5 @authors Andrei Novikov (pyclustering@yandex.ru) 7 @copyright GNU Public License 9 @cond GNU_PUBLIC_LICENSE 10 PyClustering is free software: you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation, either version 3 of the License, or 13 (at your option) any later version. 15 PyClustering is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 20 You should have received a copy of the GNU General Public License 21 along with this program. If not, see <http://www.gnu.org/licenses/>. 33 @brief Data generator provides services to generate data with clusters with normal distribution. 37 def __init__(self, amount_clusters, dimension, cluster_sizes, cluster_centers=None, cluster_width=1.0):
39 @brief Constructs data generator for generating data-sets. 41 @param[in] amount_clusters (uint): Amount of clusters that should be generated. 42 @param[in] dimension (uint): Dimension of each generated point. 43 @param[in] cluster_sizes (uint|array_like): Size of each cluster. In case of 'array_like' input clusters with 44 corresponding sizes are generated. 45 @param[in] cluster_centers (array_like): Optional parameter that defines cluster centers (means). 46 @param[in] cluster_width (uint|array_like): Optional parameter that defines cluster width (standard deviation). 47 In case of 'array_like' input each cluster has own standard deviation. 69 @brief Generates data in line with generator parameters. 77 data_points.append(point)
82 def __generate_point(self, index_cluster):
84 @brief Generates point in line with parameters of specified cluster. 86 @param[in] index_cluster (uint): Index of cluster whose parameters are used for point generation. 88 @return (list) New generated point in line with normal distribution and cluster parameters. 96 def __generate_cluster_centers(self, width):
98 @brief Generates centers (means in statistical term) for clusters. 100 @param[in] width (list): Width of generated clusters. 102 @return (list) Generated centers in line with normal distribution. 106 default_offset = max(width) * 4.0
108 center = [ random.gauss(i * default_offset, width[i] / 2.0)
for _
in range(self.
__dimension) ]
109 centers.append(center)
def __generate_cluster_centers(self, width)
Generates centers (means in statistical term) for clusters.
def __init__(self, amount_clusters, dimension, cluster_sizes, cluster_centers=None, cluster_width=1.0)
Constructs data generator for generating data-sets.
Data generator provides services to generate data with clusters with normal distribution.
def generate(self)
Generates data in line with generator parameters.
def __generate_point(self, index_cluster)
Generates point in line with parameters of specified cluster.