fix(streamlit_app): 使用绝对路径加载数据集防止路径错误

修改数据加载逻辑,使用os.path构建绝对路径来确保在不同工作目录下都能正确找到数据集文件
This commit is contained in:
2026-01-15 17:54:52 +08:00
parent df85d476db
commit d8ac31d62c
2 changed files with 4 additions and 1 deletions

Binary file not shown.

View File

@ -265,7 +265,10 @@ with col1:
with st.spinner("🔨 铁匠正在锻造武器..."):
try:
# 加载和预处理数据
df = load_data("../data/spam.csv")
# 使用绝对路径确保找到正确的数据集
import os
data_path = os.path.join(os.path.dirname(__file__), "..", "data", "spam.csv")
df = load_data(data_path)
processed_df = preprocess_data(df)
train_df, test_df = split_data(processed_df)