fix(ai_news): set weight=0 and add Spearman IC validation harness
검증 전 gradient 차단 + IC 측정 인프라. - schema.py: DEFAULT_WEIGHTS["ai_news"] 0.8 → 0.0 + 1회성 migration: 기존 운영 row 의 0.8 값 자동 reset (사용자가 명시 조정한 다른 값은 그대로 유지) - ai_news/validation.py: compute_ic() — 일자별 score_raw × forward return Spearman 상관, ic_mean/ic_std/ic_per_day 반환, verdict 분류 (skip/weak/strong) - router.py: GET /api/stock/screener/ai-news/ic?days=30&horizon=1 - 단위 테스트 5개: empty DB, strong +IC, random ≈0 IC, min_news_count 필터, horizon=5 배경: adversarial review 결과 — ai_news 가중치 0.8 이 검증 없이 출시됨. 4주+ 데이터 누적 후 IC > 0.05 확인 전까지 데이터 수집은 계속하되 가중합 영향만 차단. 운영 DB row 의 0.8 → 0.0 자동 reset 도 같은 의도. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -280,6 +280,7 @@ def list_runs(limit: int = 30):
|
||||
|
||||
from .ai_news import pipeline as _ai_pipeline
|
||||
from .ai_news import telegram as _ai_telegram
|
||||
from .ai_news import validation as _ai_validation
|
||||
|
||||
|
||||
@router.post("/snapshot/refresh-news-sentiment")
|
||||
@@ -312,6 +313,23 @@ async def post_refresh_news_sentiment(asof: Optional[str] = None):
|
||||
return summary
|
||||
|
||||
|
||||
# ---------- /ai-news/ic ----------
|
||||
|
||||
@router.get("/ai-news/ic")
|
||||
def get_ai_news_ic(days: int = 30, horizon: int = 1, min_news_count: int = 1):
|
||||
"""ai_news.score_raw 의 forward return IC (Spearman) 계산.
|
||||
|
||||
verdict:
|
||||
- skip: ic_count < 10 (데이터 부족)
|
||||
- weak: |ic_mean| <= 0.05
|
||||
- strong: |ic_mean| > 0.05 (gradient 활성화 가치 있음)
|
||||
"""
|
||||
with _conn() as c:
|
||||
return _ai_validation.compute_ic(
|
||||
c, days=days, horizon=horizon, min_news_count=min_news_count,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/runs/{run_id}")
|
||||
def get_run(run_id: int):
|
||||
with _conn() as c:
|
||||
|
||||
Reference in New Issue
Block a user