Spaces:
Sleeping
Sleeping
Delete app/routers/predictions.py
Browse files12345678910111213141516171819202122232425262728293031323334# =====================================================# app/routers/predictions.py# Son X güne ait tüm tahminleri getirir (geçmiş dahil)# =====================================================
from fastapi import APIRouter, Query, HTTPExceptionfrom app.core.hf_client import load_history
router = APIRouter()
@router.get("/predictions")def get_all_predictions(days: int = Query(7, ge=1, le=30), limit: int = Query(200, ge=1, le=2000)): """Son N güne ait tüm tahminleri döndürür (bugün dahil).""" try: df = load_history(days_back=days) if df.empty: return {"message": "Geçmiş veri yok", "count": 0, "items": []}
if "time" in df.columns: df = df.sort_values("time", ascending=False)
if "pred_label" in df.columns: df["Tahmin"] = df["pred_label"].map({1: "Yükseliş", 0: "Düşüş"}) if "pred_proba" in df.columns: df["Güven (%)"] = (df["pred_proba"] * 100).round(2)
df = df.head(limit) return { "count": len(df), "days_included": df["source_day"].unique().tolist(), "items": df.to_dict(orient="records") } except Exception as e: raise HTTPException(503, f"Tüm tahminler alınamadı: {e}")app/routers/predictions.pyDeleted-34