# Quick Start Guide

## One-Click Training Script

We provide a one-click training script for multi-task training that automatically detects and uses offline data if available.

### Basic Usage

```bash
# Navigate to release directory
cd release

# Run with default settings (auto-detects offline data)
./run_multi_task_training.sh

# Or with custom parameters
./run_multi_task_training.sh --gpu 0 --epochs 20 --batch_size 256
```

### Available Options

```bash
./run_multi_task_training.sh [OPTIONS]

Options:
  --gpu GPU_ID              GPU ID to use (default: 0)
  --epochs N                 Number of epochs (default: 20)
  --lr LEARNING_RATE         Learning rate (default: 5e-4)
  --batch_size N             Batch size (default: 256)
  --max_samples N            Max training samples, 0 for all (default: 0)
  --max_val_samples N        Max validation samples, 0 for all (default: 0)
  --max_test_samples N       Max test samples, 0 for all (default: 0)
  --num_workers N            Number of data loader workers (default: 1)
  --experiment_name NAME     Experiment name (default: auto-generated)
  --config PATH              Config file path (default: auto-detect)
  --help, -h                 Show help message
```

### Examples

**Quick test run (1 epoch, small batch):**
```bash
./run_multi_task_training.sh --epochs 1 --batch_size 32 --max_samples 100
```

**Full training:**
```bash
./run_multi_task_training.sh --gpu 0 --epochs 20 --batch_size 256 --experiment_name "my_experiment"
```

**Using specific config:**
```bash
./run_multi_task_training.sh --config exp/mimic_data/exp_mortality_24h48h_los_offline.yaml
```

### Automatic Offline Data Detection

The script automatically detects if offline sample data is available:
- If `data_dir/sample_data/sample_data.pkl` exists, it will use the offline configuration
- Otherwise, it will use the default database configuration
- No manual configuration needed!

### Output

Training results will be saved to:
- Model checkpoints: `runs/classify/{experiment_name}/best_model.pth`
- TensorBoard logs: `runs/classify/{experiment_name}/`
- Final report: `runs/classify/{experiment_name}/final_report.json`

### View Training Progress

```bash
tensorboard --logdir runs/classify
```

Open http://localhost:6006 in your browser.

### Troubleshooting

**Script not executable:**
```bash
chmod +x run_multi_task_training.sh
```

**Python not found:**
```bash
# Ensure Python 3.8+ is installed
python3 --version
```

**GPU not available:**
```bash
# Check GPU availability
nvidia-smi

# Or use CPU (slower)
./run_multi_task_training.sh --gpu ""  # Empty string for CPU
```

**Out of memory:**
```bash
# Reduce batch size
./run_multi_task_training.sh --batch_size 64
```

## Alternative: Direct Python Execution

If you prefer to run the training script directly:

```bash
python3 train_mortality_los_complete.py \
    --gpu 0 \
    --epochs 20 \
    --batch_size 256
```

The training script will automatically detect and use offline data if available.

