refactor: reorganize project structure by moving core modules and update import paths in API server
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
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)
|
||||
# Support both 'accuracy' and 'test_accuracy'
|
||||
acc = data.get('accuracy', data.get('test_accuracy', ''))
|
||||
|
||||
f1 = data.get('f1_score', '')
|
||||
precision = data.get('precision', '')
|
||||
recall = data.get('recall', '')
|
||||
|
||||
clf_rep = data.get('classification_report')
|
||||
if isinstance(clf_rep, dict) and 'macro avg' in clf_rep:
|
||||
if not f1:
|
||||
f1 = clf_rep['macro avg'].get('f1-score', '')
|
||||
if not precision:
|
||||
precision = clf_rep['macro avg'].get('precision', '')
|
||||
if not recall:
|
||||
recall = clf_rep['macro avg'].get('recall', '')
|
||||
|
||||
if not acc and not f1:
|
||||
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', ''),
|
||||
acc,
|
||||
precision,
|
||||
recall,
|
||||
f1,
|
||||
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")
|
||||
Reference in New Issue
Block a user