Exemplo n.º 1
0
 def testCluster(self):
     "Basic Hierarchical Clustering test with integers"
     cl = HierarchicalClustering(self.__data, lambda x, y: abs(x - y))
     cl.cluster()
     self.assertEqual(
         [[24], [84, 124, 131, 134], [336, 365, 365, 365, 398, 391],
          [940, 956, 971], [791], [835], [676], [518, 564, 542]],
         cl.getlevel(40))
Exemplo n.º 2
0
 def testCluster(self):
     "Basic Hierarchical Clustering test with integers"
     cl = HierarchicalClustering(self.__data, lambda x, y: abs(x - y))
     cl.cluster()
     self.assertEqual([
             [24],
             [84, 124, 131, 134],
             [336, 365, 365, 365, 398, 391],
             [940, 956, 971],
             [791],
             [835],
             [676],
             [518, 564, 542]],
             cl.getlevel(40))
def run_clustering(repository_parameter_name, start_date, end_date, limit):
    """

    :param repository_parameter_name: One of the types from ``RepositoryParameter``
    :param start_date: First day
    :param end_date: Last day
    :param limit: Limit the number of examined stations
    :return: Show clustering
    """
    params = get_repository_parameters(repository_parameter_name)
    station_repository = StationRepository(*params)
    station_dicts = station_repository.load_all_stations(start_date,
                                                         end_date,
                                                         limit=limit)
    station_time_series_comparator = StationTimeSeriesComparator(station_dicts)
    stations = [Station(station_dict) for station_dict in station_dicts]

    cluster = HierarchicalClustering(
        stations,
        station_time_series_comparator.compare_time_series,
        num_processes=4)
    cluster.cluster()
    cluster.display(print_function=logging.debug)
    logging.info(cluster._data)