82 lines
2.3 KiB
Python
Executable File
82 lines
2.3 KiB
Python
Executable File
"""
|
|
Tạo metadata cho model_odc.joblib (legacy model)
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
# Metadata cho model_odc.joblib
|
|
# Model này là GridSearchCV Pipeline với 39 features (temporal mode)
|
|
# Features: NDVI time series + NDWI time series + NDBI time series + radar features
|
|
|
|
# Calculate feature names for temporal mode with 12 timesteps
|
|
# (12 NDVI + 12 NDWI + 12 NDBI + 3 radar = 39 features)
|
|
n_timesteps = 12
|
|
feature_names = []
|
|
|
|
# NDVI time series
|
|
for t in range(n_timesteps):
|
|
feature_names.append(f"NDVI_t{t+1}")
|
|
|
|
# NDWI time series
|
|
for t in range(n_timesteps):
|
|
feature_names.append(f"NDWI_t{t+1}")
|
|
|
|
# NDBI time series
|
|
for t in range(n_timesteps):
|
|
feature_names.append(f"NDBI_t{t+1}")
|
|
|
|
# Radar features
|
|
feature_names.extend(["VH_db_mean", "VV_db_mean", "VH_VV_ratio"])
|
|
|
|
metadata = {
|
|
"timestamp": "2025-12-20T10:00:00",
|
|
"data_source": "Unknown (Legacy model)",
|
|
"collections": ["sentinel-2-l2a", "sentinel-1-rtc"],
|
|
"features": feature_names,
|
|
"feature_mode": "temporal", # IMPORTANT: temporal mode with 39 features
|
|
"training_samples": None,
|
|
"testing_samples": None,
|
|
"test_size": 0.2,
|
|
"train_accuracy": None,
|
|
"test_accuracy": None,
|
|
"model_type": "random_forest", # GridSearchCV with RandomForest
|
|
"device": "cpu",
|
|
"n_estimators": 100,
|
|
"max_depth": None,
|
|
"learning_rate": None,
|
|
"cnn_epochs": None,
|
|
"n_features": 39, # GridSearchCV expects 39 features!
|
|
"n_classes": 8,
|
|
"class_names": [
|
|
"Lua tom", # 0
|
|
"Lua", # 1
|
|
"CHN", # 2
|
|
"CLN", # 3
|
|
"TS", # 4
|
|
"Song", # 5
|
|
"Dat xay dung", # 6
|
|
"Rung" # 7
|
|
],
|
|
"classification_report": None,
|
|
"confusion_matrix": None,
|
|
"bbox": None,
|
|
"time_range": None,
|
|
"resolution": 10,
|
|
"notes": "Legacy GridSearchCV Pipeline model with 39 temporal features (12 timesteps each for NDVI/NDWI/NDBI + 3 radar features). Requires temporal mode feature extraction."
|
|
}
|
|
|
|
# Save metadata
|
|
model_train_dir = Path("model_train")
|
|
metadata_file = model_train_dir / "model_odc_info.json"
|
|
|
|
print("Creating metadata for model_odc.joblib...")
|
|
print(f"Saving to: {metadata_file}")
|
|
|
|
with open(metadata_file, 'w') as f:
|
|
json.dump(metadata, f, indent=2)
|
|
|
|
print("✅ Metadata created successfully!")
|
|
print("\nMetadata content:")
|
|
print(json.dumps(metadata, indent=2))
|