From 1f28c887f1de7a3580b2d8bee0cf19a2cdb24011 Mon Sep 17 00:00:00 2001 From: XianBW <36835909+XianBW@users.noreply.github.com> Date: Thu, 26 Sep 2024 14:35:22 +0800 Subject: [PATCH] feat: show workspace in demo (#348) * change id name in s4e8 tpl * add workspace in demo * add workspace in demo * fix CI * change workspace path color --- rdagent/log/ui/app.py | 3 +++ .../fea_share_preprocess.py | 4 ++-- .../experiment/playground-series-s4e8_template/train.py | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rdagent/log/ui/app.py b/rdagent/log/ui/app.py index 66e5bd38..e82c5d9d 100644 --- a/rdagent/log/ui/app.py +++ b/rdagent/log/ui/app.py @@ -536,6 +536,9 @@ def feedback_window(): if isinstance(state.scenario, KGScenario): if fbe := state.msgs[round]["ef.runner result"]: submission_path = fbe[0].content.experiment_workspace.workspace_path / "submission.csv" + st.markdown( + f":green[**Exp Workspace**]: {str(fbe[0].content.experiment_workspace.workspace_path.absolute())}" + ) st.download_button( label="**Download** submission.csv", data=submission_path.read_bytes(), diff --git a/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/fea_share_preprocess.py b/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/fea_share_preprocess.py index eb79fd85..329b103b 100644 --- a/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/fea_share_preprocess.py +++ b/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/fea_share_preprocess.py @@ -92,8 +92,8 @@ def preprocess_script(): # Load and preprocess the test data submission_df = pd.read_csv("/kaggle/input/test.csv") - passenger_ids = submission_df["id"] + ids = submission_df["id"] submission_df = submission_df.drop(["id"], axis=1) X_test = preprocess_transform(submission_df, preprocessor, numerical_cols, categorical_cols) - return X_train, X_valid, y_train, y_valid, X_test, passenger_ids + return X_train, X_valid, y_train, y_valid, X_test, ids diff --git a/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/train.py b/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/train.py index f65a38d8..752d459c 100644 --- a/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/train.py +++ b/rdagent/scenarios/kaggle/experiment/playground-series-s4e8_template/train.py @@ -30,8 +30,7 @@ def import_module_from_path(module_name, module_path): # 1) Preprocess the data -# TODO 如果已经做过数据预处理了,不需要再做了 -X_train, X_valid, y_train, y_valid, X_test, passenger_ids = preprocess_script() +X_train, X_valid, y_train, y_valid, X_test, ids = preprocess_script() # 2) Auto feature engineering X_train_l, X_valid_l = [], [] @@ -106,7 +105,7 @@ y_valid_pred = np.mean(y_valid_pred_l, axis=0) y_valid_pred = (y_valid_pred > 0.5).astype(int) mcc = compute_metrics_for_classification(y_valid, y_valid_pred) -print("Final on validation set: ", mcc) +print("MCC on validation set: ", mcc) # 6) Save the validation accuracy pd.Series(data=[mcc], index=["MCC"]).to_csv("submission_score.csv") @@ -122,5 +121,5 @@ y_test_pred = (y_test_pred > 0.5).astype(int) y_test_pred_labels = np.where(y_test_pred == 1, "p", "e") # 将整数转换回 'e' 或 'p' # 8) Submit predictions for the test set -submission_result = pd.DataFrame({"id": passenger_ids, "class": y_test_pred_labels.ravel()}) +submission_result = pd.DataFrame({"id": ids, "class": y_test_pred_labels.ravel()}) submission_result.to_csv("submission.csv", index=False)