feat(analyzer): score_combination에 weights 파라미터 추가 (None=기존 fixed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 03:06:26 +09:00
parent a4614ebeae
commit 1694823129
2 changed files with 66 additions and 6 deletions

View File

@@ -170,7 +170,11 @@ def build_number_weights(cache: Dict[str, Any]) -> Dict[int, float]:
return weights
def score_combination(numbers: List[int], cache: Dict[str, Any]) -> Dict[str, float]:
def score_combination(
numbers: List[int],
cache: Dict[str, Any],
weights: Optional[List[float]] = None,
) -> Dict[str, float]:
"""
6개 번호 조합의 통계적 품질 점수 계산 (0~1 범위 정규화).
@@ -181,6 +185,13 @@ def score_combination(numbers: List[int], cache: Dict[str, Any]) -> Dict[str, fl
- score_cooccur (15%): 공동 출현 기댓값 대비
- score_diversity (10%): 연속번호, 범위, 구간 다양성
Args:
numbers: 6개 번호 리스트
cache: build_analysis_cache() 반환 딕셔너리
weights: 5가지 기법별 가중치 리스트 [frequency, fingerprint, gap, cooccur, diversity].
None이면 기본값 [0.25, 0.30, 0.20, 0.15, 0.10] 사용.
길이가 5가 아니면 ValueError 발생.
Returns:
{"score_total": ..., "score_frequency": ..., ...}
"""
@@ -282,12 +293,16 @@ def score_combination(numbers: List[int], cache: Dict[str, Any]) -> Dict[str, fl
)
# ── 최종 가중 합산 ────────────────────────────────────────────────────────
if weights is None:
weights = [0.25, 0.30, 0.20, 0.15, 0.10]
if len(weights) != 5:
raise ValueError("weights must have 5 elements")
score_total = (
score_frequency * 0.25
+ score_fingerprint * 0.30
+ score_gap * 0.20
+ score_cooccur * 0.15
+ score_diversity * 0.10
score_frequency * weights[0]
+ score_fingerprint * weights[1]
+ score_gap * weights[2]
+ score_cooccur * weights[3]
+ score_diversity * weights[4]
)
return {