From c1d8b9d5fe3d44392caca9960c1c0078a5867496 Mon Sep 17 00:00:00 2001 From: smirnovavyu Date: Fri, 4 Sep 2026 15:15:48 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20Sm?= =?UTF-8?q?irnovaVYu/docs/data/visualize.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SmirnovaVYu/docs/data/visualize.py | 77 ------------------------------ 1 file changed, 77 deletions(-) delete mode 100644 SmirnovaVYu/docs/data/visualize.py diff --git a/SmirnovaVYu/docs/data/visualize.py b/SmirnovaVYu/docs/data/visualize.py deleted file mode 100644 index 70117f6b..00000000 --- a/SmirnovaVYu/docs/data/visualize.py +++ /dev/null @@ -1,77 +0,0 @@ -import pandas as pd -import matplotlib.pyplot as plt -import numpy as np -from pathlib import Path - - -def plot_results(csv_file='experiment_results.csv'): - - if not Path(csv_file).exists(): - print(f"❌ {csv_file} не найден. Сначала запустите main.py") - return - - df = pd.read_csv(csv_file) - - df = df[df['path_found'] == True] - - if df.empty: - print("Нет данных для графиков") - return - - mazes = [m.replace('.txt', '') for m in df['maze_file'].unique()] - strategies = df['strategy'].unique() - - fig, axes = plt.subplots(1, 3, figsize=(14, 5)) - fig.suptitle('Сравнение алгоритмов поиска в лабиринте', fontsize=14, fontweight='bold') - - x = np.arange(len(mazes)) - width = 0.25 - colors = {'BFS': '#3498db', 'DFS': '#2ecc71', 'A*': '#e74c3c'} - - for i, strategy in enumerate(strategies): - times, visited, lengths = [], [], [] - - for maze in df['maze_file'].unique(): - data = df[(df['strategy'] == strategy) & (df['maze_file'] == maze)] - if not data.empty: - times.append(data['time_mean'].values[0]) - visited.append(data['visited_mean'].values[0]) - lengths.append(data['path_length_mean'].values[0]) - else: - times.append(0) - visited.append(0) - lengths.append(0) - - axes[0].bar(x + i*width, times, width, label=strategy, - color=colors.get(strategy, 'gray'), alpha=0.7) - axes[1].bar(x + i*width, visited, width, label=strategy, - color=colors.get(strategy, 'gray'), alpha=0.7) - axes[2].bar(x + i*width, lengths, width, label=strategy, - color=colors.get(strategy, 'gray'), alpha=0.7) - - axes[0].set_title(' Время выполнения (мс)') - axes[0].set_xticks(x + width) - axes[0].set_xticklabels(mazes, rotation=45, ha='right') - axes[0].legend() - axes[0].grid(True, alpha=0.3) - - axes[1].set_title(' Посещённые клетки') - axes[1].set_xticks(x + width) - axes[1].set_xticklabels(mazes, rotation=45, ha='right') - axes[1].legend() - axes[1].grid(True, alpha=0.3) - - axes[2].set_title(' Длина пути') - axes[2].set_xticks(x + width) - axes[2].set_xticklabels(mazes, rotation=45, ha='right') - axes[2].legend() - axes[2].grid(True, alpha=0.3) - - plt.tight_layout() - plt.savefig('experiment_results.png', dpi=150, bbox_inches='tight') - plt.show() - - - -if __name__ == "__main__": - plot_results() \ No newline at end of file