From 91881d564a6c9a678eda7e342471c5cb2561715b Mon Sep 17 00:00:00 2001 From: DXC Date: Wed, 17 Jun 2026 14:15:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Step8=20=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=94=9F=E6=88=90=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=8F=8A=E7=89=B9=E5=BE=81=E5=88=86=E7=A6=BB=E6=9C=AA=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=9D=90=E6=A0=87=E5=88=97=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=200=20=E6=A8=A1=E5=9E=8B=20Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - view 层 Step8View.update_work_directory 不再生成 /indices/_indices.csv,改为生成标准的 /8_Modeling/ 模型存放目录;FileSelectWidget 标签与文件过滤器同步调整为目录语义(输出模型目录 / All Files (*.*)),消除'保存目录被存成 csv 文件'导致的 train_models 跳过判定。 --- src/core/modeling/modeling_batch.py | 19 ++++++++++++++++--- src/new/views/step8_view.py | 22 ++++++++-------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/core/modeling/modeling_batch.py b/src/core/modeling/modeling_batch.py index 2079f81..1597033 100644 --- a/src/core/modeling/modeling_batch.py +++ b/src/core/modeling/modeling_batch.py @@ -288,11 +288,24 @@ class WaterQualityModelingBatch: # 提取所有目标列(从0列到feature_start_index-1列) y_dict = {} target_columns = data.columns[:feature_start_index] - - print(f"检测到的目标列: {list(target_columns)}") - + print(f"检测到的潜在目标列: {list(target_columns)}") + + # 新增:跳过非预测目标的系统保留列 + ignore_cols = {'ID', 'id', 'Id', 'Longitude', 'Latitude', 'Lon', 'Lat', 'longitude', 'latitude', 'lon', 'lat', 'Station', 'station'} + for col_name in target_columns: + # 过滤黑名单列 + if col_name in ignore_cols: + print(f" 跳过目标列 '{col_name}': 属于系统保留列或空间坐标") + continue + y_series = data[col_name] + + # 过滤非数值类型列 (避免将纯文本备注等拿去回归) + if not pd.api.types.is_numeric_dtype(y_series): + print(f" 跳过目标列 '{col_name}': 非数值类型") + continue + # 检查是否有非空值 if not y_series.isna().all(): y_dict[col_name] = y_series diff --git a/src/new/views/step8_view.py b/src/new/views/step8_view.py index 9f9e5bf..d067c6f 100644 --- a/src/new/views/step8_view.py +++ b/src/new/views/step8_view.py @@ -141,10 +141,10 @@ class Step8View(BaseView): # 输出文件路径 self.output_path = FileSelectWidget( - "输出文件:", - "CSV Files (*.csv);;All Files (*.*)", + "输出模型目录:", + "All Files (*.*)", ) - self.output_path.line_edit.setPlaceholderText("自动生成,或手动指定输出文件路径...") + self.output_path.line_edit.setPlaceholderText("自动生成模型存放目录...") layout.addWidget(self.output_path) # 启用步骤 @@ -301,17 +301,11 @@ class Step8View(BaseView): step6_training_csv = os.path.join(step6_dir, "training_spectra.csv").replace("\\", "/") if not self.training_csv_file.get_path(): self.training_csv_file.set_path(step6_training_csv) - # 自动填输出路径 - indices_dir = _resolve_subdir(work_dir, "indices") - os.makedirs(indices_dir, exist_ok=True) - training_csv = self.training_csv_file.get_path() - if training_csv: - basename = os.path.splitext(os.path.basename(training_csv))[0] - output_file = f"{basename}_indices.csv" - else: - output_file = "training_spectra_indices.csv" - output_path = os.path.join(indices_dir, output_file).replace("\\", "/") - self.output_path.set_path(output_path) + + # ⬇️ 修复:生成标准的输出目录路径 + models_dir = _resolve_subdir(work_dir, "8_Modeling") + os.makedirs(models_dir, exist_ok=True) + self.output_path.set_path(models_dir) # ------------------------------------------------------------------ # 执行入口