111 lines
3.7 KiB
Python
111 lines
3.7 KiB
Python
import os
|
|
import glob
|
|
import json
|
|
import subprocess
|
|
import time
|
|
from tabulate import tabulate
|
|
|
|
scripts = [
|
|
"train_land_randomforest.py",
|
|
"train_cloud_cnn.py",
|
|
"train_cloud_swin_unet.py",
|
|
"train_ndvi_statistical.py",
|
|
"train_ndvi_lstm_gru.py",
|
|
"train_ndvi_convlstm.py",
|
|
"train_ndvi_hybrid_physics.py",
|
|
"train_ndvi_ensemble.py"
|
|
]
|
|
|
|
print("🚀 Đang khởi chạy song song tất cả các mô hình...")
|
|
processes = []
|
|
for script in scripts:
|
|
if os.path.exists(script):
|
|
cmd = f"source /home/x79/miniconda3/etc/profile.d/conda.sh && conda activate env_01 && python {script}"
|
|
p = subprocess.Popen(["bash", "-c", cmd], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
processes.append((script, p))
|
|
|
|
for script, p in processes:
|
|
p.wait()
|
|
|
|
print("✅ Đã chạy xong tất cả các mô hình!\n")
|
|
print("📊 BẢNG SO SÁNH KẾT QUẢ CÁC MÔ HÌNH\n")
|
|
|
|
# 1. Phân loại đất
|
|
print("### 1. Nhóm Phân loại Lớp phủ (Land Classification)")
|
|
land_data = []
|
|
|
|
# Đọc XGBoost từ thư mục gốc
|
|
if os.path.exists("model_xgboost_info.json"):
|
|
with open("model_xgboost_info.json", 'r') as f:
|
|
data = json.load(f)
|
|
params = data.get('params', {})
|
|
param_str = f"estimators:{params.get('n_estimators')}, depth:{params.get('max_depth')}" if params else "N/A"
|
|
land_data.append([
|
|
data.get('model_type', 'XGBoost'),
|
|
data.get('accuracy', ''),
|
|
data.get('precision', ''),
|
|
data.get('recall', ''),
|
|
data.get('f1_score', ''),
|
|
param_str
|
|
])
|
|
|
|
# Đọc các model khác trong model_train
|
|
for info_file in glob.glob("model_train/*_info.json"):
|
|
with open(info_file, 'r') as f:
|
|
data = json.load(f)
|
|
# Chỉ lấy các model có độ chính xác (để lọc model rác/cũ)
|
|
if 'accuracy' not in data and 'f1_score' not in data:
|
|
continue
|
|
|
|
params = data.get('params', {})
|
|
param_str = f"estimators:{params.get('n_estimators')}, depth:{params.get('max_depth')}" if params else "N/A"
|
|
|
|
# Fallback for Random Forest
|
|
if data.get('model_type') == 'RandomForest_RealData':
|
|
param_str = "estimators:100, depth:15"
|
|
|
|
land_data.append([
|
|
data.get('model_type', ''),
|
|
data.get('accuracy', ''),
|
|
data.get('precision', ''),
|
|
data.get('recall', ''),
|
|
data.get('f1_score', ''),
|
|
param_str
|
|
])
|
|
|
|
if land_data:
|
|
print(tabulate(land_data, headers=["Model", "Accuracy", "Precision", "Recall", "F1-Score", "Parameters"], tablefmt="github"))
|
|
print("\n")
|
|
|
|
# 2. Xóa mây
|
|
print("### 2. Nhóm Xóa mây (Cloud Removal)")
|
|
cloud_data = []
|
|
for info_file in glob.glob("cloud_removal_model/*_info.json"):
|
|
with open(info_file, 'r') as f:
|
|
data = json.load(f)
|
|
cloud_data.append([
|
|
data.get('model_type', ''),
|
|
data.get('epoch', ''),
|
|
data.get('train_loss', ''),
|
|
data.get('val_loss', '')
|
|
])
|
|
if cloud_data:
|
|
print(tabulate(cloud_data, headers=["Model", "Epochs", "Train Loss", "Val Loss"], tablefmt="github"))
|
|
print("\n")
|
|
|
|
# 3. Dự báo NDVI
|
|
print("### 3. Nhóm Dự báo Thực vật (NDVI Forecasting)")
|
|
ndvi_data = []
|
|
for info_file in glob.glob("ndvi_forecast_model/*_info.json"):
|
|
with open(info_file, 'r') as f:
|
|
data = json.load(f)
|
|
ndvi_data.append([
|
|
data.get('model_type', ''),
|
|
data.get('rmse', ''),
|
|
data.get('mae', ''),
|
|
data.get('epoch', 'N/A')
|
|
])
|
|
if ndvi_data:
|
|
print(tabulate(ndvi_data, headers=["Model", "RMSE", "MAE", "Epochs"], tablefmt="github"))
|
|
print("\n")
|