import pickle
import os

def load_model(file_path):
    """
    加载保存的模型文件。
    
    :param file_path: 模型文件的路径
    :return: 加载的模型
    """
    with open(file_path, 'rb') as f:
        model = pickle.load(f)
    return model

# 你需要替换为实际的文件路径
# file_path = 'model_optimize/pkl/rf_model_1207_1530.pkl'
# file_path = r'pkl\rf_model_0308_1619.pkl'
file_path = r'pkl\rf_model_0308_1632.pkl'


# 加载模型
loaded_model = load_model(file_path)

# 读取模型的超参数
n_estimators = loaded_model.n_estimators
max_depth = loaded_model.max_depth
min_samples_split = loaded_model.min_samples_split
min_samples_leaf = loaded_model.min_samples_leaf
max_features = loaded_model.max_features

# 打印超参数
print(f"n_estimators: {n_estimators}")
print(f"max_depth: {max_depth}")
print(f"min_samples_split: {min_samples_split}")
print(f"min_samples_leaf: {min_samples_leaf}")
print(f"max_features: {max_features}")
