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
This commit is contained in:
XianBW
2024-09-26 14:35:22 +08:00
committed by GitHub
parent 5300d9345c
commit 1f28c887f1
3 changed files with 8 additions and 6 deletions
+3
View File
@@ -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(),
@@ -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
@@ -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)