Pārlūkot izejas kodu

version two 阶段性最终版本 2025/5/13

ziqidai11 3 nedēļas atpakaļ
vecāks
revīzija
03902063f7
4 mainītis faili ar 7 papildinājumiem un 7 dzēšanām
  1. BIN
      WTI/1234_update.xlsx
  2. 3 3
      WTI/Rbob.py
  3. 4 4
      WTI/model_metrics.json
  4. BIN
      WTI/update.xlsx

BIN
WTI/1234_update.xlsx


+ 3 - 3
WTI/Rbob.py

@@ -136,6 +136,7 @@ SPECIAL_REVERSE = {
     }
 }
 
+METRICS_JSON = 'model_metrics.json'
 
 # ------------ 数据加载与预处理 ------------
 def load_and_preprocess_data():
@@ -362,10 +363,9 @@ def evaluate_and_predict(model, scaler, X_tr, y_tr, X_te, y_te, X_fu, use_tuning
     }
 
     # 保存为JSON
-    json_path = './model_metrics.json'
-    with open(json_path, 'w', encoding='utf-8') as f:
+    with open(METRICS_JSON, 'w', encoding='utf-8') as f:
         json.dump([metrics], f, ensure_ascii=False, indent=4)
-    print(f"评估指标已保存至 {json_path}")
+    print(f"评估指标已保存至 {METRICS_JSON}")
 
     return y_tr_pred, y_te_pred, y_fu_pred
 

+ 4 - 4
WTI/model_metrics.json

@@ -1,8 +1,8 @@
 [
     {
-        "train_mse": 0.5177,
-        "test_mse": 5.158,
-        "train_r2": 0.9925,
-        "test_r2": -3.146
+        "train_mse": 0.5091,
+        "test_mse": 5.172,
+        "train_r2": 0.9926,
+        "test_r2": -3.157
     }
 ]

BIN
WTI/update.xlsx