Azure VM(vm-nego-daegu, Ubuntu 20.04.6 / Python 3.10.14) 실행 결과를 정본에 반영. 로컬과 Azure의 모든 측정 산출물 md5 일치 확인함. - ② 협상성공률(대인): extract_file.py 신설 — testdata/human_data.xlsx 전수 499건 집계, 성공 = 협상완료 ∧ AI협상결과 '성공'. 76.35% PASS (목표 75%). 구 extract_from_negowiz.py 제거 - ③ 평균가격협상률: eval/03_price_reduction/ 신설 — ①의 detail_*.jsonl에서 LLM 재실행 없이 독립 집계. 5.877% PASS (목표 3%), ①의 자체 산출값과 일치 - ⑥ 답변속도: 실트래픽 7,179건 집계 result.json 신설 (p95 25.37ms PASS) + 부하 측정분(heavy p95 57.9ms / light p95 41.25ms) - ①⑦⑧⑨⑩: Azure 본측정 산출물(detail·result·스냅샷·모델) 추가 - server/data: 측정 증거 로그를 Azure 실행분으로 교체 (response_time 195→7,182줄, contracts 301줄, tension_log 2,251줄) 보류: 최저가 탐색 탭(frontend PriceSearchPanel·server price_search.py)은 사용자 코드 정리 대기 중이라 이번 커밋에서 제외. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sLpiFCT7Lj78iLwPbVx7a
80 lines
3.4 KiB
Python
80 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""③ 평균 가격 협상률 — ① 측정 로그에서 독립 집계.
|
|
|
|
협상률 = (기존 공급가 − 최종 합의가) / 기존 공급가. 협상완료(합의) 건만 평균. 목표 3%.
|
|
①의 detail_*.jsonl에 건별 reduction_pct가 남아 있어 LLM 재실행 없이 산출한다.
|
|
|
|
사용: python aggregate.py [--source ../01_win_rate/본측정300_azure_20260901] [--target 3]
|
|
출력: data/reduction_all.csv 건별 원자료 (모델·기존공급가·합의가·협상률)
|
|
data/reduction_all_meta.json 출처·산식·모델별·분포
|
|
result.json 건수 + 평균 협상률 + PASS/FAIL
|
|
"""
|
|
import argparse
|
|
import csv
|
|
import json
|
|
import statistics
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).parent
|
|
DEFAULT_SOURCE = HERE.parent / "01_win_rate" / "본측정300_azure_20260901"
|
|
FORMULA = "협상완료 합의 건의 (기존 공급가 − 최종 합의가) / 기존 공급가 평균"
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser(description=__doc__.split("\n", 1)[0])
|
|
ap.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
|
|
ap.add_argument("--target", type=float, default=3.0)
|
|
args = ap.parse_args()
|
|
|
|
files = sorted(args.source.glob("detail_*.jsonl"))
|
|
if not files:
|
|
sys.exit(f"detail_*.jsonl 이 없습니다: {args.source}")
|
|
|
|
cases = [(f.stem[len("detail_"):].replace("_", "."), json.loads(line))
|
|
for f in files for line in f.open(encoding="utf-8")]
|
|
agreed = [(m, c) for m, c in cases if c.get("reduction_pct") is not None]
|
|
if not agreed:
|
|
sys.exit("합의(협상완료) 건이 없습니다")
|
|
reds = [c["reduction_pct"] for _, c in agreed]
|
|
avg = round(sum(reds) / len(reds), 3)
|
|
|
|
out = HERE / "data"
|
|
out.mkdir(exist_ok=True)
|
|
with open(out / "reduction_all.csv", "w", encoding="utf-8-sig", newline="") as f:
|
|
w = csv.writer(f)
|
|
w.writerow(["모델", "case_id", "견적번호", "기존공급가", "최종합의가", "협상률_pct"])
|
|
for model, c in agreed:
|
|
w.writerow([model, c["case_id"], c.get("quotation_number"),
|
|
c["prev_price"], c["final_price"], c["reduction_pct"]])
|
|
|
|
by_model = {}
|
|
for model, c in agreed:
|
|
by_model.setdefault(model, []).append(c["reduction_pct"])
|
|
(out / "reduction_all_meta.json").write_text(json.dumps({
|
|
"출처": f"{args.source.name} — {len(files)}개 detail_*.jsonl, 전체 {len(cases)}건",
|
|
"산식": FORMULA,
|
|
"모델별": {m: {"합의건수": len(v), "avg_reduction_pct": round(sum(v) / len(v), 3)}
|
|
for m, v in by_model.items()},
|
|
"분포_pct": {"최소": min(reds), "중앙값": round(statistics.median(reds), 3),
|
|
"최대": max(reds), "표준편차": round(statistics.pstdev(reds), 3)},
|
|
}, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
|
|
result = {
|
|
"전체 건수": len(cases),
|
|
"합의 건수": len(agreed),
|
|
"미합의 건수": len(cases) - len(agreed),
|
|
"평균가격협상률_pct": avg,
|
|
"산식": FORMULA,
|
|
"목표_pct": args.target,
|
|
"verdict": "PASS" if avg >= args.target else "FAIL",
|
|
"상세": "data/reduction_all_meta.json",
|
|
}
|
|
(HERE / "result.json").write_text(
|
|
json.dumps(result, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
print(json.dumps(result, ensure_ascii=False, indent=1))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|