自动填写路径
This commit is contained in:
@ -2284,11 +2284,15 @@ class WaterQualityInversionPipeline:
|
||||
else:
|
||||
raise ValueError("请先执行步骤6: 训练机器学习模型,或提供models_dir参数")
|
||||
|
||||
# 检查prediction_dir中是否已有预测结果文件
|
||||
# 设置机器学习预测输出子目录
|
||||
ml_prediction_dir = self.prediction_dir / "Machine_Learning_Prediction"
|
||||
ml_prediction_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 检查Machine_Learning_Prediction子目录中是否已有预测结果文件
|
||||
prediction_files = {}
|
||||
if self.prediction_dir.exists():
|
||||
if ml_prediction_dir.exists():
|
||||
# 查找所有CSV预测结果文件
|
||||
csv_files = list(self.prediction_dir.glob('*.csv'))
|
||||
csv_files = list(ml_prediction_dir.glob('*.csv'))
|
||||
if csv_files:
|
||||
# 从文件名提取目标参数名(假设文件名为"target_name_prediction.csv")
|
||||
for csv_file in csv_files:
|
||||
@ -2312,11 +2316,11 @@ class WaterQualityInversionPipeline:
|
||||
# 检查是否所有目标参数都有预测文件
|
||||
missing_targets = [t for t in target_folders if t not in prediction_files]
|
||||
if not missing_targets:
|
||||
print(f"检测到已存在的预测结果文件,直接使用: {self.prediction_dir}")
|
||||
print(f"检测到已存在的预测结果文件,直接使用: {ml_prediction_dir}")
|
||||
print(f"找到 {len(prediction_files)} 个预测结果文件")
|
||||
step_end_time = time.time()
|
||||
self._record_step_time("步骤8: 预测水质参数", step_start_time, step_end_time, status="skipped")
|
||||
print(f"预测结果已设置: {self.prediction_dir}")
|
||||
print(f"预测结果已设置: {ml_prediction_dir}")
|
||||
return prediction_files
|
||||
else:
|
||||
print(f"检测到部分预测结果文件,缺少以下目标参数: {missing_targets}")
|
||||
@ -2329,7 +2333,7 @@ class WaterQualityInversionPipeline:
|
||||
all_results = inferencer.batch_inference_multi_models(
|
||||
models_root_dir=models_path,
|
||||
sampling_csv_path=sampling_csv_path,
|
||||
output_dir=str(self.prediction_dir),
|
||||
output_dir=str(ml_prediction_dir),
|
||||
metric=metric,
|
||||
prediction_column=prediction_column,
|
||||
output_format='csv'
|
||||
@ -2342,7 +2346,7 @@ class WaterQualityInversionPipeline:
|
||||
|
||||
step_end_time = time.time()
|
||||
self._record_step_time("步骤8: 预测水质参数", step_start_time, step_end_time)
|
||||
print(f"预测完成,结果保存在: {self.prediction_dir}")
|
||||
print(f"预测完成,结果保存在: {ml_prediction_dir}")
|
||||
|
||||
# 生成预测结果报告
|
||||
try:
|
||||
@ -3731,15 +3735,17 @@ class WaterQualityInversionPipeline:
|
||||
else:
|
||||
raise ValueError("请先执行步骤6.5: 非经验模型训练,或提供non_empirical_models_dir参数")
|
||||
|
||||
# 检查预测目录中是否已有预测结果文件
|
||||
prediction_files = {}
|
||||
# 设置非经验模型预测输出子目录
|
||||
if output_path is not None:
|
||||
non_empirical_prediction_dir = Path(output_path)
|
||||
else:
|
||||
# 使用和步骤8相同的prediction_dir目录,但文件名添加non_empirical_前缀
|
||||
non_empirical_prediction_dir = self.prediction_dir
|
||||
# 使用Non_Empirical_Prediction子目录
|
||||
non_empirical_prediction_dir = self.prediction_dir / "Non_Empirical_Prediction"
|
||||
non_empirical_prediction_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 检查预测目录中是否已有预测结果文件
|
||||
prediction_files = {}
|
||||
|
||||
# 查找汇总CSV文件
|
||||
summary_path = Path(final_models_dir) / "non_empirical_models_summary.csv"
|
||||
if not summary_path.exists():
|
||||
@ -3876,9 +3882,11 @@ class WaterQualityInversionPipeline:
|
||||
else:
|
||||
raise ValueError("请先执行步骤6.75: 自定义回归分析,或提供custom_regression_dir参数")
|
||||
|
||||
# 确定输出目录
|
||||
# 设置自定义回归预测输出子目录
|
||||
if output_dir is None:
|
||||
prediction_output_dir = str(self.prediction_dir)
|
||||
custom_regression_prediction_dir = self.prediction_dir / "Custom_Regression_Prediction"
|
||||
custom_regression_prediction_dir.mkdir(parents=True, exist_ok=True)
|
||||
prediction_output_dir = str(custom_regression_prediction_dir)
|
||||
else:
|
||||
prediction_output_dir = output_dir
|
||||
|
||||
|
||||
Reference in New Issue
Block a user