로또 종합 추론 API 추가 (5가지 통계 기법 가중 투표)
- analyzer.py: generate_combined_recommendation() 함수 추가 빈도Z(25%)·조합지문(30%)·갭(20%)·공동출현(15%)·다양성(10%) 가중 투표 - main.py: GET /api/lotto/recommend/combined 엔드포인트 추가 결과를 태그 "종합추론"으로 recommendations 테이블에 저장 - main.py: GET /api/lotto/recommend/combined/history 엔드포인트 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ from .collector import sync_latest, sync_ensure_all
|
||||
from .generator import run_simulation, generate_smart_recommendations
|
||||
from .checker import check_results_for_draw
|
||||
from .utils import calc_metrics, calc_recent_overlap
|
||||
from .analyzer import get_statistical_report, generate_weekly_report, analyze_personal_patterns
|
||||
from .analyzer import get_statistical_report, generate_weekly_report, analyze_personal_patterns, generate_combined_recommendation
|
||||
|
||||
app = FastAPI()
|
||||
scheduler = BackgroundScheduler(timezone=os.getenv("TZ", "Asia/Seoul"))
|
||||
@@ -389,6 +389,46 @@ def api_simulation(run_id: Optional[int] = None, runs_limit: int = 5):
|
||||
}
|
||||
|
||||
|
||||
# ── 종합 추론 추천 ───────────────────────────────────────────────────────────
|
||||
|
||||
@app.get("/api/lotto/recommend/combined")
|
||||
def api_recommend_combined():
|
||||
"""5가지 통계 기법 종합 추론 추천 — 결과를 이력에 저장한다."""
|
||||
draws = get_all_draw_numbers()
|
||||
if not draws:
|
||||
raise HTTPException(status_code=404, detail="No data")
|
||||
|
||||
latest = get_latest_draw()
|
||||
result = generate_combined_recommendation(draws)
|
||||
if "error" in result:
|
||||
raise HTTPException(status_code=500, detail=result["error"])
|
||||
|
||||
# 추천 이력 저장 (태그: 종합추론)
|
||||
params = {"method": "combined"}
|
||||
saved = save_recommendation_dedup(
|
||||
latest["drw_no"] if latest else None,
|
||||
result["final_numbers"],
|
||||
params,
|
||||
)
|
||||
if saved["saved"]:
|
||||
update_recommendation(saved["id"], tags=["종합추론"])
|
||||
|
||||
return {
|
||||
**result,
|
||||
"id": saved["id"],
|
||||
"saved": saved["saved"],
|
||||
"deduped": saved["deduped"],
|
||||
"based_on_latest_draw": latest["drw_no"] if latest else None,
|
||||
}
|
||||
|
||||
|
||||
@app.get("/api/lotto/recommend/combined/history")
|
||||
def api_combined_history(limit: int = 30):
|
||||
"""종합추론 추천 이력 조회."""
|
||||
items = list_recommendations_ex(limit=limit, tag="종합추론", sort="id_desc")
|
||||
return {"items": items, "total": len(items)}
|
||||
|
||||
|
||||
# ── 기존 수동 추천 API (하위 호환 유지) ─────────────────────────────────────
|
||||
@app.get("/api/lotto/recommend")
|
||||
def api_recommend(
|
||||
|
||||
Reference in New Issue
Block a user