Ejemplo n.º 1
0
 def __update_centers(self):
     """!
     @brief Calculate centers of clusters in line with contained objects.
     
     @return (list) Updated centers as list of centers.
     
     """
      
     centers = [[] for i in range(len(self.__clusters))];
      
     for index in range(len(self.__clusters)):
         point_sum = [0] * len(self.__pointer_data[0]);
          
         for index_point in self.__clusters[index]:
             point_sum = list_math_addition(point_sum, self.__pointer_data[index_point]);
         
         centers[index] = list_math_division_number(point_sum, len(self.__clusters[index]));
          
     return centers;
Ejemplo n.º 2
0
 def __update_centers(self):
     """!
     @brief Calculate centers of clusters in line with contained objects.
     
     @return (list) Updated centers as list of centers.
     
     """
      
     centers = [[] for i in range(len(self.__clusters))];
      
     for index in range(len(self.__clusters)):
         point_sum = [0] * len(self.__pointer_data[0]);
          
         for index_point in self.__clusters[index]:
             point_sum = list_math_addition(point_sum, self.__pointer_data[index_point]);
         
         centers[index] = list_math_division_number(point_sum, len(self.__clusters[index]));
          
     return centers;
Ejemplo n.º 3
0
def __get_centers(data, clusters):
    """
@brief Centers of clusters in line with contained objects.
    @param[in] clusters (list): Clusters that contain indexes of objects from data.
    @return (list) Centers.

    """

    centers = [[] for i in range(len(clusters))]
    dimension = len(data[0])

    for index in range(len(clusters)):
        point_sum = [0.0] * dimension

        for index_point in clusters[index]:
            point_sum = list_math_addition(point_sum, data[index_point])

        centers[index] = list_math_division_number(point_sum,
                                                   len(clusters[index]))

    return centers
Ejemplo n.º 4
0
 def __update_centers(self, clusters):
     """!
     @brief Updates centers of clusters in line with contained objects.
     
     @param[in] clusters (list): Clusters that contain indexes of objects from data.
     
     @return (list) Updated centers.
     
     """
      
     centers = [[] for _ in range(len(clusters))];
     dimension = len(self.__pointer_data[0])
       
     for index in range(len(clusters)):
         point_sum = [0.0] * dimension;
           
         for index_point in clusters[index]:
             point_sum = list_math_addition(point_sum, self.__pointer_data[index_point]);
         
         centers[index] = list_math_division_number(point_sum, len(clusters[index]));
           
     return centers;
Ejemplo n.º 5
0
 def __update_centers(self, clusters):
     """!
     @brief Updates centers of clusters in line with contained objects.
     
     @param[in] clusters (list): Clusters that contain indexes of objects from data.
     
     @return (list) Updated centers.
     
     """
      
     centers = [[] for i in range(len(clusters))];
     dimension = len(self.__pointer_data[0])
       
     for index in range(len(clusters)):
         point_sum = [0.0] * dimension;
           
         for index_point in clusters[index]:
             point_sum = list_math_addition(point_sum, self.__pointer_data[index_point]);
         
         centers[index] = list_math_division_number(point_sum, len(clusters[index]));
           
     return centers;