Spaces:
Runtime error
Runtime error
File size: 2,445 Bytes
0ad96be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #!/bin/bash
set -euo pipefail
# ==========================================
# MedModel Training Configuration
# ==========================================
# Data and Model Configs
DATA_CONFIG="./configs/preoperative.json"
MODEL_CONFIG="./configs/parameters.json"
# Models to train (leave empty "" to train all models in parameters.json)
MODELS="hgb,rf,svc,torch_mlp"
# Splitting Strategy: 'random', 'predefined', or 'temporal'
SPLIT_STRATEGY="temporal"
SPLIT_COLUMN="Split"
TEST_SIZE="0.2"
DATE_COLUMN="Date of surgery"
# FN-sensitive decision policy (binary tasks)
THRESHOLD_VAL_SIZE="0.2"
MIN_RECALL="0.90"
F_BETA="2.0"
FN_COST="5.0"
FP_COST="1.0"
# Optional extras
FEATURE_IMPORTANCE="false"
# ==========================================
# Run Training Script
# ==========================================
# Define the list of target variables
TARGETS=(
"complications_30d"
"Severe complication"
"KPS_Discharge Worsened"
"New neurological deficits"
)
echo "Starting MedModel Training Pipeline..."
echo "Split Strategy: $SPLIT_STRATEGY"
echo "=========================================="
# Loop through each target
for TARGET_COLUMN in "${TARGETS[@]}"; do
# Update the output directory dynamically for each target
OUTPUT_DIR="./outputs/$TARGET_COLUMN"
echo ""
echo ">>> Training for Target: $TARGET_COLUMN"
echo ">>> Output Directory: $OUTPUT_DIR"
# Build the command dynamically
CMD="python ./src/train.py \
--target \"$TARGET_COLUMN\" \
--data_config \"$DATA_CONFIG\" \
--model_config \"$MODEL_CONFIG\" \
--output_folder \"$OUTPUT_DIR\" \
--split_strategy \"$SPLIT_STRATEGY\" \
--test_size $TEST_SIZE \
--split_column \"$SPLIT_COLUMN\" \
--date_column \"$DATE_COLUMN\" \
--threshold_val_size $THRESHOLD_VAL_SIZE \
--min_recall $MIN_RECALL \
--f_beta $F_BETA \
--fn_cost $FN_COST \
--fp_cost $FP_COST"
# Add models argument if it's not empty
if [ -n "$MODELS" ]; then
CMD="$CMD --models \"$MODELS\""
fi
if [ "$FEATURE_IMPORTANCE" = "true" ]; then
CMD="$CMD --feature_importance"
fi
# Execute the training command
eval $CMD
echo ">>> Finished training for: $TARGET_COLUMN"
echo "------------------------------------------"
done
echo ""
echo "All experiments finished! Check the './outputs/' folder for results."
|