| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import os | |
| def create_correlation_heatmap(corr_data, session_id): | |
| plt.figure(figsize=(6, 4)) | |
| sns.heatmap(corr_data, annot=False, cmap="coolwarm") | |
| file_path = f"{session_id}_correlation.png" | |
| plt.title("Correlation Heatmap") | |
| plt.savefig(file_path, bbox_inches="tight") | |
| plt.close() | |
| return file_path | |
| def create_feature_importance_chart(feature_data, session_id): | |
| plt.figure(figsize=(6, 4)) | |
| names = list(feature_data.keys()) | |
| values = list(feature_data.values()) | |
| plt.barh(names, values) | |
| plt.title("Top Features") | |
| file_path = f"{session_id}_features.png" | |
| plt.savefig(file_path, bbox_inches="tight") | |
| plt.close() | |
| return file_path | |
| def create_cluster_chart(cluster_sizes, session_id): | |
| plt.figure(figsize=(6, 4)) | |
| labels = list(cluster_sizes.keys()) | |
| values = list(cluster_sizes.values()) | |
| plt.bar(labels, values) | |
| plt.title("Cluster Distribution") | |
| file_path = f"{session_id}_clusters.png" | |
| plt.savefig(file_path, bbox_inches="tight") | |
| plt.close() | |
| return file_path |