示例#1
0
    def __train_metis_model(self, c):
        matrices = FileManager().get_ensembling_matrices(
            self.name, self.are_clusters_fixed)
        for key, value in matrices.items():
            if key == 'CO':
                model = MetisClustering(value, c)
                assignations = model.clusterize()[1]
                FileManager().save_results(assignations, self.name, key,
                                           self.are_clusters_fixed, 'Metis')
            else:
                features = len(value[0])
                graph = nx.Graph()
                graph.add_nodes_from(list(range(self.num_rows)))
                graph.add_nodes_from(
                    list(range(self.num_rows, self.num_rows + features)))
                for cnt_row, rows in enumerate(value):
                    for cnt_col, col in enumerate(rows):
                        graph.add_edge(cnt_row,
                                       self.num_rows + cnt_col,
                                       weight=col)

                model = MetisClustering(value, c, graph)
                assignations = model.clusterize()[1][:self.num_rows]
                FileManager().save_results(assignations, self.name, key,
                                           self.are_clusters_fixed, 'Metis')
        Validator(self.name, self.numerical, self.ground_truth, 'Metis',
                  self.are_clusters_fixed).validate_consensus()
示例#2
0
 def __train_spectral_model(self, c):
     matrices = FileManager().get_ensembling_matrices(
         self.name, self.are_clusters_fixed)
     for key, value in matrices.items():
         model = Spectral(value, c)
         assignations = model.clusterize()
         FileManager().save_results(assignations, self.name, key,
                                    self.are_clusters_fixed, 'Spectral')
     Validator(self.name, self.numerical, self.ground_truth, 'Spectral',
               self.are_clusters_fixed).validate_consensus()
示例#3
0
    def __train_ahc_model(self, c, link=None, algorithm='SL'):
        matrices = FileManager().get_ensembling_matrices(
            self.name, self.are_clusters_fixed)
        for key, value in matrices.items():
            model = Agglomerative(value, c, ahc_linkage=link)
            assignations = model.clusterize()
            FileManager().save_results(assignations, self.name, key,
                                       self.are_clusters_fixed, algorithm)

        Validator(self.name, self.numerical, self.ground_truth, algorithm,
                  self.are_clusters_fixed).validate_consensus()