Spaces:
Sleeping
Sleeping
Update app/routers/predictions.py
Browse files9 unmodified lines101112131415161718192021222324252627289 unmodified lines@router.get("/predictions")def get_predictions(day: str = Query(None)):"""Belirli bir günün veya bugünün tahmin detaylarını JSON formatında döndürür."""try:df = load_day_csv(day) if day else download_latest_csv()df = df.sort_values("time", ascending=False).head(200)# Türkçe etiketler ekledf["Tahmin"] = df["pred_label"].map({1: "Yükseliş", 0: "Düşüş"})if "pred_proba" in df:df["Güven (%)"] = (df["pred_proba"] * 100).round(2)return {"count": len(df),"day": df["source_day"].iloc[0],"items": df.to_dict(orient="records")}except Exception as e:9 unmodified lines101112131415161718192021222324252627282930319 unmodified lines@router.get("/predictions")def get_predictions(day: str = Query(None)):"""Belirli bir günün veya bugünün tahmin detaylarını döndürür."""try:df = load_day_csv(day) if day else download_latest_csv()if df.empty:return {"message": "Boş veri dosyası", "count": 0, "items": []}if "time" in df.columns:df = df.sort_values("time", ascending=False).head(200)df["Tahmin"] = df.get("pred_label", 0).map({1: "Yükseliş", 0: "Düşüş"})if "pred_proba" in df.columns:df["Güven (%)"] = (df["pred_proba"] * 100).round(2)return {"count": len(df),"day": df["source_day"].iloc[0] if "source_day" in df.columns else "unknown","items": df.to_dict(orient="records")}except Exception as e:
app/routers/predictions.py+9-6