hoàn thành chức năng tính ndvi analysys 2 màn hình
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
Inspect model_odc.joblib to see what it actually contains
|
||||
"""
|
||||
|
||||
import joblib
|
||||
from pathlib import Path
|
||||
|
||||
model_path = Path("model_train/model_odc.joblib")
|
||||
|
||||
if model_path.exists():
|
||||
print("Loading model_odc.joblib...")
|
||||
model_data = joblib.load(model_path)
|
||||
|
||||
print(f"\nModel type: {type(model_data)}")
|
||||
print(f"Model class: {model_data.__class__.__name__}")
|
||||
|
||||
# Check if it's a dict
|
||||
if isinstance(model_data, dict):
|
||||
print(f"\nModel is a dict with keys: {model_data.keys()}")
|
||||
model = model_data.get('model')
|
||||
else:
|
||||
model = model_data
|
||||
|
||||
print(f"\nActual model type: {type(model)}")
|
||||
print(f"Actual model class: {model.__class__.__name__}")
|
||||
|
||||
# Try to get feature info
|
||||
if hasattr(model, 'n_features_in_'):
|
||||
print(f"\nn_features_in_: {model.n_features_in_}")
|
||||
|
||||
if hasattr(model, 'feature_names_in_'):
|
||||
print(f"feature_names_in_: {model.feature_names_in_}")
|
||||
|
||||
# If it's a GridSearchCV
|
||||
if hasattr(model, 'best_estimator_'):
|
||||
print(f"\nThis is a GridSearchCV!")
|
||||
print(f"Best estimator: {model.best_estimator_}")
|
||||
|
||||
best_est = model.best_estimator_
|
||||
if hasattr(best_est, 'steps'):
|
||||
print(f"\nPipeline steps:")
|
||||
for step_name, step in best_est.steps:
|
||||
print(f" - {step_name}: {step.__class__.__name__}")
|
||||
if hasattr(step, 'n_features_in_'):
|
||||
print(f" n_features_in_: {step.n_features_in_}")
|
||||
|
||||
# If it's a Pipeline
|
||||
if hasattr(model, 'steps'):
|
||||
print(f"\nThis is a Pipeline!")
|
||||
print(f"Pipeline steps:")
|
||||
for step_name, step in model.steps:
|
||||
print(f" - {step_name}: {step.__class__.__name__}")
|
||||
if hasattr(step, 'n_features_in_'):
|
||||
print(f" n_features_in_: {step.n_features_in_}")
|
||||
|
||||
# Try to get booster for XGBoost
|
||||
try:
|
||||
if hasattr(model, 'get_booster'):
|
||||
print(f"\nXGBoost num_features: {model.get_booster().num_features()}")
|
||||
except:
|
||||
pass
|
||||
|
||||
else:
|
||||
print(f"Model file not found: {model_path}")
|
||||
Reference in New Issue
Block a user