## Metric

Submissions are evaluated using **Macro-Averaged Area Under the Receiver Operating Characteristic Curve (AUC-ROC)**, computed independently for each binary target and averaged with equal weight.

$$\text{Score} = \frac{\text{AUC}(\hat{y}\_{\text{adverse\_outcome}},\ y\_{\text{adverse\_outcome}}) + \text{AUC}(\hat{y}\_{\text{readmission\_30d}},\ y\_{\text{readmission\_30d}})}{2}$$

where \(\hat{y}\) denotes predicted probabilities in \([0, 1]\) and \(y\) denotes the binary ground truth labels. AUC is computed using the trapezoidal rule as implemented in `sklearn.metrics.roc_auc_score`.

| Property | Value |
|----------|-------|
| Range | 0.0 to 1.0 |
| Direction | Higher is better |
| Random classifier baseline | 0.5000 |
| Perfect classifier | 1.0000 |

---

## Baseline Reference Scores

| Model | AUC adverse\_outcome | AUC readmission\_30d | Macro AUC |
|-------|--------------------|--------------------|-----------|
| Constant prediction | 0.5000 | 0.5000 | 0.5000 |
| Logistic Regression (vital signs only) | 0.8251 | 0.6842 | 0.7547 |
| LightGBM (all features, 5-fold CV) | 0.9123 | 0.7891 | 0.8507 |

Scores are computed via 5-fold stratified cross-validation on `train.csv` as reported in `setup_solution.ipynb`.

---

## Submission File

For each `encounter_id` in the test set, you must predict a probability for `adverse_outcome` and a probability for `readmission_30d`. Both values must be continuous floats in \([0, 1]\). The file must contain a header and have the following format:
```apache
encounter_id,adverse_outcome,readmission_30d
TR-ED-00700001,0.34218,0.09841
TR-ED-00700002,0.72193,0.23407
TR-ED-00700003,0.08552,0.05123
```

The submission file must contain exactly 200,000 rows. All `encounter_id` values must match the test set exactly with no duplicates or omissions. NaN, Inf, or out-of-range values will cause submission rejection.

---

## Leaderboard

The public leaderboard is evaluated on a randomly selected **50% of the test encounters** and is updated after each submission. The private leaderboard is evaluated on the remaining **50%** and is revealed after the Final Submission Deadline. Participants must select up to **2 Final Submissions** for private leaderboard scoring. If no selection is made, the system automatically selects the 2 submissions with the highest public leaderboard scores.

---

## Evaluation Code
```python
from sklearn.metrics import roc_auc_score
import numpy as np

def competition_score(y_true_df, y_pred_df):
    targets = ["adverse_outcome", "readmission_30d"]
    merged = y_true_df.merge(y_pred_df, on="encounter_id", suffixes=("_true", "_pred"))
    auc_scores = []
    for col in targets:
        auc = roc_auc_score(merged[f"{col}_true"], merged[f"{col}_pred"])
        auc_scores.append(auc)
        print(f"AUC {col}: {auc:.5f}")
    macro_auc = np.mean(auc_scores)
    print(f"Macro AUC: {macro_auc:.5f}")
    return macro_auc
```