Esempio n. 1
0
	def save_cluster_metrics(self, points, predictions, key, level2_mode = False):

		try:
			silhoutte_global = metrics.silhouette_score(points, predictions, metric='euclidean')
			silhoutte_weighted = utils.silhoutte_weighted(points, predictions)

			self.silhouette_scores_global[key] = silhoutte_global
			self.silhouette_scores_weighted[key] = silhoutte_weighted

			if level2_mode:
				self.level2_silhoutte_global.append(silhoutte_global)
				self.level2_silhoutte_weighted.append(silhoutte_weighted)

		except ValueError as e:
			pass

		# dunn_scores = cluster_evaluation.dunn_index(points, predictions, means)

		dunn_scores = [0, 0, 0]

		if (dunn_scores[0] is not None) and (dunn_scores[1] is not None) and (dunn_scores[2] is not None):

			self.dunn_scores_1[key] = dunn_scores[0]
			self.dunn_scores_2[key] = dunn_scores[1]
			self.dunn_scores_3[key] = dunn_scores[2]

			if level2_mode:
				self.level2_dunn_1.append(dunn_scores[0])
				self.level2_dunn_2.append(dunn_scores[1])
				self.level2_dunn_3.append(dunn_scores[2])
	def save_cluster_metrics(self, points, predictions, key):
		"""
		Utility function calculates clustering metrics whenever
		clustering is performed in the algorithm.
		"""
		if key == 'level1':
			self.silhouette_score_global = metrics.silhouette_score(points, predictions, metric='euclidean')
			self.silhouette_score_weighted = utils.silhoutte_weighted(points, predictions)

		# dunn_scores = cluster_evaluation.dunn_index(points, predictions, means)

		dunn_scores = [0,0,0]

		if (dunn_scores[0] is not None) and (dunn_scores[1] is not None) and (dunn_scores[2] is not None):

			self.dunn_scores_1[key] = dunn_scores[0]
			self.dunn_scores_2[key] = dunn_scores[1]
			self.dunn_scores_3[key] = dunn_scores[2]
	def save_cluster_metrics(self, points, predictions, key):
		"""
		Utility function calculates clustering metrics whenever
		clustering is performed in the algorithm.
		"""
		if key == 'level1':
			self.silhouette_score_global = metrics.silhouette_score(points, predictions, metric='euclidean')
			self.silhouette_score_weighted = utils.silhoutte_weighted(points, predictions)

		# dunn_scores = cluster_evaluation.dunn_index(points, predictions, means)

		dunn_scores = [0,0,0]

		if (dunn_scores[0] is not None) and (dunn_scores[1] is not None) and (dunn_scores[2] is not None):

			self.dunn_scores_1[key] = dunn_scores[0]
			self.dunn_scores_2[key] = dunn_scores[1]
			self.dunn_scores_3[key] = dunn_scores[2]
Esempio n. 4
0
    def save_cluster_metrics(self,
                             points,
                             predictions,
                             key,
                             level2_mode=False):

        try:
            silhoutte_global = metrics.silhouette_score(points,
                                                        predictions,
                                                        metric='euclidean')
            silhoutte_weighted = utils.silhoutte_weighted(points, predictions)

            self.silhouette_scores_global[key] = silhoutte_global
            self.silhouette_scores_weighted[key] = silhoutte_weighted

            if level2_mode:
                self.level2_silhoutte_global.append(silhoutte_global)
                self.level2_silhoutte_weighted.append(silhoutte_weighted)

        except ValueError as e:
            pass

        # dunn_scores = cluster_evaluation.dunn_index(points, predictions, means)

        dunn_scores = [0, 0, 0]

        if (dunn_scores[0] is not None) and (dunn_scores[1]
                                             is not None) and (dunn_scores[2]
                                                               is not None):

            self.dunn_scores_1[key] = dunn_scores[0]
            self.dunn_scores_2[key] = dunn_scores[1]
            self.dunn_scores_3[key] = dunn_scores[2]

            if level2_mode:
                self.level2_dunn_1.append(dunn_scores[0])
                self.level2_dunn_2.append(dunn_scores[1])
                self.level2_dunn_3.append(dunn_scores[2])