import os import glob import json from tabulate import tabulate 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 = [] 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 ]) for info_file in glob.glob("model_train/*_info.json"): with open(info_file, 'r') as f: data = json.load(f) 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" 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")