Initial commit: ML-Porosity project setup
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
36
test 2/read_npz_output.py
Normal file
36
test 2/read_npz_output.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.metrics import mean_squared_error
|
||||
from scipy.stats import pearsonr
|
||||
|
||||
# === Load file ===
|
||||
data = np.load(r"C:\Users\PC\Documents\Thesis\outputs\open_loop_patch_preds_F06-1_v2.npz", allow_pickle=True)
|
||||
print("Keys trong file:", data.files)
|
||||
|
||||
# === Giả định các key là ===
|
||||
# y_true: porosity từ well-logging
|
||||
# y_pred: porosity dự đoán
|
||||
# times_ms: trục thời gian
|
||||
y_true = data['y_true']
|
||||
y_pred = data['y_pred']
|
||||
times = data['times_ms'] if 'times_ms' in data.files else np.arange(len(y_true))
|
||||
|
||||
# === Tính toán ===
|
||||
mse = mean_squared_error(y_true, y_pred)
|
||||
pcc, _ = pearsonr(y_true, y_pred)
|
||||
|
||||
print(f"[🔍] MSE: {mse:.4f}")
|
||||
print(f"[🔍] PCC: {pcc:.4f}")
|
||||
|
||||
# === Vẽ biểu đồ ===
|
||||
plt.figure(figsize=(10,5))
|
||||
plt.plot(times, y_true, label='True Porosity', linewidth=2)
|
||||
plt.plot(times, y_pred, label='Predicted Porosity', linestyle='--')
|
||||
plt.xlabel("Time (ms)")
|
||||
plt.ylabel("Porosity")
|
||||
plt.title(f"F06-1 Porosity Comparison\nMSE={mse:.4f} | PCC={pcc:.4f}")
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
plt.savefig(r"C:\Users\PC\Documents\Thesis\outputs\porosity_comparison_F06-1.png")
|
||||
Reference in New Issue
Block a user