ClarusC64's picture
Create prediction_baseline.py
fd859ca verified
raw
history blame contribute delete
915 Bytes
import pandas as pd
df = pd.read_csv("data/tester.csv")
# naive baseline:
# predict unstable if boundary is very small or drift is strongly positive
df["prediction"] = (
(df["boundary_distance"] <= 0.08) |
(df["drift_gradient"] >= 0.07)
).astype(int)
# optional intervention direction baseline
def predict_direction(row):
if pd.isna(row["boundary_distance_before"]) or pd.isna(row["boundary_distance_after"]):
return None
if row["boundary_distance_after"] > row["boundary_distance_before"]:
return 1
if row["boundary_distance_after"] < row["boundary_distance_before"]:
return -1
return 0
df["intervention_effect_direction"] = df.apply(predict_direction, axis=1)
out = df[["scenario_id", "prediction", "intervention_effect_direction"]]
out.to_csv("predictions.csv", index=False)
print("Baseline predictions written to predictions.csv")
print(f"rows: {len(out)}")