From ca3fdf03ca3e1f86a6b5ddfbba030e9a591fb5e4 Mon Sep 17 00:00:00 2001 From: Danya_Mochalov Date: Fri, 26 Apr 2024 22:02:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=2011=20=D1=81=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab11/lab11.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lab11/lab11.py b/lab11/lab11.py index e9e54d6..8fb9373 100644 --- a/lab11/lab11.py +++ b/lab11/lab11.py @@ -8,7 +8,6 @@ def get_distance(first: np.ndarray, second: np.ndarray) -> float: return math.sqrt(sum([(first[i] - second[i]) ** 2 for i in range(first.shape[0])])) + 1e-5 -# Расчёт степени принадлежности def affiliation_calculation(data: np.ndarray, centers: np.ndarray, k: int, m: int) -> np.ndarray: data_len = data.shape[0] u = np.zeros((data_len, k)) @@ -22,7 +21,6 @@ def affiliation_calculation(data: np.ndarray, centers: np.ndarray, k: int, m: in return u -# Расчёт отклонения def variance_calculation(data: np.ndarray, centers: np.ndarray, u: np.ndarray) -> float: value = 0 for j in range(k): @@ -31,7 +29,6 @@ def variance_calculation(data: np.ndarray, centers: np.ndarray, u: np.ndarray) - return value -# Обновление центров кластеров def center_update(data: np.ndarray, u: np.ndarray, k: int, m: int) -> np.ndarray: centers = np.zeros((k, data.shape[1])) for j in range(k): @@ -63,7 +60,6 @@ def fuzzy_c_means(data: np.ndarray, k: int, m: int, max_iter: int = 100, tol: fl return centers, u, value -# Работа с plt для визуализации результата def visualise_resout(centers: np.ndarray, u: np.ndarray): center_colors = [[random.random(), random.random(), random.random()] for i in range(k)] point_colors = [] @@ -78,7 +74,6 @@ def visualise_resout(centers: np.ndarray, u: np.ndarray): plt.title("Нечёткая кластеризация") plt.xlabel("Размер зарплаты") - # Визуализация if data.shape[1] == 1: plt.scatter(data[:, 0], [0] * data.shape[0], c=point_colors) plt.scatter(centers[:, 0], [0] * centers.shape[0], marker='*', edgecolor='black', s=100, c=center_colors)