Files
iqa-study/scripts/fr_fusion/plotting.py
T
2025-04-12 03:19:13 +01:00

38 lines
1.0 KiB
Python

'''
Filename: plotting.py
Path: /home/netoa/Desktop/ISR/scripts
Created Date: Monday March 24th 2025
Author: Andre Neto
-----
Last Modified: Tue Mar 25 2025
Modified By: Andre Neto
-----
Copyright (c) 2025 Institute of Systems and Robotics
'''
import os
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
def plot_fusion_result(y_true, y_pred, model_name, output_dir):
"""Scatter plot: MOS vs predicted fused score."""
os.makedirs(output_dir, exist_ok=True)
plt.figure(figsize=(6, 6))
sns.scatterplot(x=y_pred, y=y_true, alpha=0.6, color="blue")
z = np.polyfit(y_pred, y_true, 1)
p = np.poly1d(z)
plt.plot(y_pred, p(y_pred), color="red", linewidth=2)
plt.xlabel("Predicted Fused Score")
plt.ylabel("MOS")
plt.title(f"MOS vs Predicted ({model_name})")
plt.grid(True, linestyle="--", alpha=0.5)
plt.tight_layout()
plt.savefig(os.path.join(output_dir, f"fusion_plot_{model_name}.png"), dpi=300)
plt.savefig(os.path.join(output_dir, f"fusion_plot_{model_name}.eps"), dpi=300)
plt.close()