Datasets:
Create prediction_baseline.py
Browse files- prediction_baseline.py +28 -0
prediction_baseline.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
df = pd.read_csv("data/tester.csv")
|
| 4 |
+
|
| 5 |
+
# naive baseline:
|
| 6 |
+
# predict unstable if boundary is very small or drift is strongly positive
|
| 7 |
+
df["prediction"] = (
|
| 8 |
+
(df["boundary_distance"] <= 0.08) |
|
| 9 |
+
(df["drift_gradient"] >= 0.07)
|
| 10 |
+
).astype(int)
|
| 11 |
+
|
| 12 |
+
# optional intervention direction baseline
|
| 13 |
+
def predict_direction(row):
|
| 14 |
+
if pd.isna(row["boundary_distance_before"]) or pd.isna(row["boundary_distance_after"]):
|
| 15 |
+
return None
|
| 16 |
+
if row["boundary_distance_after"] > row["boundary_distance_before"]:
|
| 17 |
+
return 1
|
| 18 |
+
if row["boundary_distance_after"] < row["boundary_distance_before"]:
|
| 19 |
+
return -1
|
| 20 |
+
return 0
|
| 21 |
+
|
| 22 |
+
df["intervention_effect_direction"] = df.apply(predict_direction, axis=1)
|
| 23 |
+
|
| 24 |
+
out = df[["scenario_id", "prediction", "intervention_effect_direction"]]
|
| 25 |
+
out.to_csv("predictions.csv", index=False)
|
| 26 |
+
|
| 27 |
+
print("Baseline predictions written to predictions.csv")
|
| 28 |
+
print(f"rows: {len(out)}")
|