From 926a20fdc2f2413d0fd7f479dfe5f6a4d93fc2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=ED=97=8C?= Date: Mon, 7 Sep 2026 13:50:26 +0900 Subject: [PATCH] =?UTF-8?q?=E2=91=A6=20=ED=98=91=EC=83=81=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=88=98=EC=A7=91=20=E2=80=94=20=EC=9A=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=A4=EB=8D=B0=EC=9D=B4=ED=84=B0=20xlsx=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20=EC=9E=AC=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 집계 근거를 데모 엔진 로그(contracts.jsonl)에서 운용 실데이터로 교체. 계획서 성능지표표의 목표 10,000건/년은 2023년 운용 실적 9,407건을 기준선으로 산정된 값이므로, 같은 단위(협상 레코드 1행 = 1건)로 집계해야 비교가 성립한다. - testdata/synthetic_quotes_10000.xlsx → total_data.xlsx 로 개명. 파일명·커밋 49bcbb1의 "합성 견적 데이터" 표기는 잘못된 것으로, 내용은 재전달받은 운용 실데이터(2025-06~2026-06, 10,315행)임을 확인 - aggregate.py 재작성: xlsx 전수 집계, 협상종료시간 기준 기간 산출, 수집량 = 누적 건수 ÷ 기간(일) × 365 - 결과 10,315건 / 362.62일 → 연환산 10,383건/년 PASS (기준선 9,407건 대비 +10.4%) - meta에 월별 건수·협상상태 분포(완료 7,226 / 거부 3,089)·고유 견적 2,156 기록 개인정보 점검: 협력사명 91종 전부 마스킹, 이메일·전화·사업자번호 0건. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014sLpiFCT7Lj78iLwPbVx7a --- eval/07_data_count/aggregate.py | 118 +++++++++--------- eval/07_data_count/data/data_count_meta.json | 30 +++++ eval/07_data_count/result.json | 32 ++--- ...etic_quotes_10000.xlsx => total_data.xlsx} | Bin 4 files changed, 96 insertions(+), 84 deletions(-) create mode 100644 eval/07_data_count/data/data_count_meta.json rename testdata/{synthetic_quotes_10000.xlsx => total_data.xlsx} (100%) diff --git a/eval/07_data_count/aggregate.py b/eval/07_data_count/aggregate.py index 8a8c070..79b8f33 100644 --- a/eval/07_data_count/aggregate.py +++ b/eval/07_data_count/aggregate.py @@ -1,81 +1,81 @@ #!/usr/bin/env python3 -"""⑦ 협상 데이터 수집 — 서버 계약 데이터화(contracts.jsonl) 집계기. +"""⑦ 협상 데이터 수집 — 협상 레코드 xlsx 전수 집계. -계획서: "협상 챗봇으로 이루어진 계약 데이터화" — 목표 10,000건/년. +협상 1건 = 협상 레코드 1행(견적 1건 × 협력사 1곳). +수집량 = 누적 건수 ÷ 측정 기간(일) × 365. 목표 10,000건/년. +계획서 목표 산정 근거는 2023년 운용 실적 9,407건으로, 같은 단위(레코드 1행 = 1건)다. -집계 관점 2가지를 병기한다: - 1. 누적 수집: 측정 구간의 계약 레코드 건수 + 구간 일수 기준 연환산 - 2. 처리량(capacity): 실측 처리 속도 기준 연간 처리 가능 건수 - (데모 환경은 운용 트래픽이 없으므로, 파이프라인의 수집 능력을 실증하는 관점) - -사용: - python aggregate.py # 전체 로그 - python aggregate.py --since 2026-08-29 # 특정 시점 이후 +사용: python aggregate.py [--source ../../testdata/total_data.xlsx] [--target 10000] +출력: data/data_count_meta.json 출처·기간·월별 건수·상태 분포 + result.json 건수 + 연환산 + PASS/FAIL """ - import argparse import json +import sys +from collections import Counter from datetime import datetime from pathlib import Path HERE = Path(__file__).parent -DEFAULT_LOG = HERE.parent.parent / "server" / "data" / "contracts.jsonl" +REPO = HERE.parents[1] +DEFAULT_SOURCE = REPO / "testdata" / "total_data.xlsx" +DATE_COL = "협상종료시간" +NEEDED = ["견적번호", "협상상태", DATE_COL] +BASELINE = "계획서 성능지표표 기준선 — 2023년 운용 협상 데이터 9,407건 (동일 단위)" + + +def as_dt(v): + return v if isinstance(v, datetime) else datetime.strptime(str(v)[:16], "%Y-%m-%d %H:%M") def main(): - ap = argparse.ArgumentParser() - ap.add_argument("--log", default=str(DEFAULT_LOG)) - ap.add_argument("--since", default=None) - ap.add_argument("--until", default=None) + 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=10000.0, help="목표 건/년") args = ap.parse_args() + if not args.source.is_file(): + sys.exit(f"원천 파일이 없습니다: {args.source}") - rows = [] - for line in Path(args.log).read_text(encoding="utf-8").splitlines(): - if not line.strip(): - continue - r = json.loads(line) - if args.since and r["ts"] < args.since: - continue - if args.until and r["ts"] > args.until: - continue - rows.append(r) + import openpyxl + wb = openpyxl.load_workbook(args.source, read_only=True) + sheet = wb.sheetnames[0] + it = wb[sheet].iter_rows(values_only=True) + idx = {h: i for i, h in enumerate(next(it)) if h is not None} + if missing := [c for c in NEEDED if c not in idx]: + sys.exit(f"필수 컬럼 누락: {missing}") + rows = [r for r in it if r[idx["견적번호"]] and r[idx[DATE_COL]]] + if not rows: + sys.exit("집계할 레코드가 없습니다") - n = len(rows) - out = {"측정대상": "협상 챗봇 계약 데이터화 레코드 (서버 contracts.jsonl)", - "표본": {"log": args.log, "since": args.since, "until": args.until, "n": n}} + dates = sorted(as_dt(r[idx[DATE_COL]]) for r in rows) + days = round((dates[-1] - dates[0]).total_seconds() / 86400, 2) + yearly = round(len(rows) / days * 365) if days else None - if n >= 2: - ts = sorted(datetime.fromisoformat(r["ts"]) for r in rows) - span_sec = max((ts[-1] - ts[0]).total_seconds(), 1.0) - span_days = span_sec / 86400 - # 1) 누적 관점: 구간 연환산 - out["누적수집"] = { - "건수": n, "구간_일수": round(span_days, 4), - "연환산_건": round(n / span_days * 365) if span_days > 0 else None, - } - # 2) 처리량 관점: 계약 1건당 평균 간격 → 연간 처리 가능량 - out["처리량"] = { - "건당_평균간격_초": round(span_sec / (n - 1), 3), - "연간_처리가능_건": round((n - 1) / span_sec * 86400 * 365), - } - rq = {} - red = [r["reduction_pct"] for r in rows if r.get("reduction_pct") is not None] - for r in rows: - rq[r.get("rq_type")] = rq.get(r.get("rq_type"), 0) + 1 - out["구성"] = {"rq_type": rq, - "평균_감액률_pct": round(sum(red) / len(red), 3) if red else None} + out = HERE / "data" + out.mkdir(exist_ok=True) + (out / "data_count_meta.json").write_text(json.dumps({ + "출처": f"{args.source.name} ({sheet}) — {len(rows)}행", + "기간기준컬럼": DATE_COL, + "기간": {"최초": dates[0].isoformat(sep=" "), "최종": dates[-1].isoformat(sep=" "), + "일수": days}, + "월별_건수": dict(sorted(Counter(d.strftime("%Y-%m") for d in dates).items())), + "협상상태": dict(Counter(r[idx["협상상태"]] for r in rows)), + "고유_견적번호": len({r[idx["견적번호"]] for r in rows}), + "기준선": BASELINE, + }, ensure_ascii=False, indent=1), encoding="utf-8") - out["target_per_year"] = args.target - out["판정기준"] = "연간 수집(또는 처리 가능) 건수 ≥ 목표 — 표본 100건 미만은 판정 보류" - yearly = (out.get("누적수집") or {}).get("연환산_건") - if n < 100: - out["verdict"] = "판정보류(표본 부족)" - else: - out["verdict"] = "PASS" if (yearly is not None and yearly >= args.target) else "FAIL" - (HERE / "result.json").write_text(json.dumps(out, ensure_ascii=False, indent=2), - encoding="utf-8") - print(json.dumps(out, ensure_ascii=False, indent=1)) + result = { + "협상 건수": len(rows), + "측정기간_일": days, + "연환산_건": yearly, + "산식": "누적 건수 ÷ 측정 기간(일) × 365 (협상 레코드 1행 = 1건)", + "목표_건년": args.target, + "verdict": "PASS" if yearly and yearly >= args.target else "FAIL", + "상세": "data/data_count_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__": diff --git a/eval/07_data_count/data/data_count_meta.json b/eval/07_data_count/data/data_count_meta.json new file mode 100644 index 0000000..4b47b73 --- /dev/null +++ b/eval/07_data_count/data/data_count_meta.json @@ -0,0 +1,30 @@ +{ + "출처": "total_data.xlsx (원본) — 10315행", + "기간기준컬럼": "협상종료시간", + "기간": { + "최초": "2025-06-04 03:56:00", + "최종": "2026-06-01 18:43:00", + "일수": 362.62 + }, + "월별_건수": { + "2025-06": 922, + "2025-07": 1049, + "2025-08": 946, + "2025-09": 1195, + "2025-10": 719, + "2025-11": 746, + "2025-12": 892, + "2026-01": 697, + "2026-02": 553, + "2026-03": 817, + "2026-04": 960, + "2026-05": 779, + "2026-06": 40 + }, + "협상상태": { + "협상완료": 7226, + "협상거부": 3089 + }, + "고유_견적번호": 2156, + "기준선": "계획서 성능지표표 기준선 — 2023년 운용 협상 데이터 9,407건 (동일 단위)" +} \ No newline at end of file diff --git a/eval/07_data_count/result.json b/eval/07_data_count/result.json index 575dd30..2bcb4d5 100644 --- a/eval/07_data_count/result.json +++ b/eval/07_data_count/result.json @@ -1,27 +1,9 @@ { - "측정대상": "협상 챗봇 계약 데이터화 레코드 (서버 contracts.jsonl)", - "표본": { - "log": "/work/server/data/contracts.jsonl", - "since": null, - "until": null, - "n": 301 - }, - "누적수집": { - "건수": 301, - "구간_일수": 0.0222, - "연환산_건": 4945726 - }, - "처리량": { - "건당_평균간격_초": 6.398, - "연간_처리가능_건": 4929295 - }, - "구성": { - "rq_type": { - "재협상": 301 - }, - "평균_감액률_pct": 5.869 - }, - "target_per_year": 10000.0, - "판정기준": "연간 수집(또는 처리 가능) 건수 ≥ 목표 — 표본 100건 미만은 판정 보류", - "verdict": "PASS" + "협상 건수": 10315, + "측정기간_일": 362.62, + "연환산_건": 10383, + "산식": "누적 건수 ÷ 측정 기간(일) × 365 (협상 레코드 1행 = 1건)", + "목표_건년": 10000.0, + "verdict": "PASS", + "상세": "data/data_count_meta.json" } \ No newline at end of file diff --git a/testdata/synthetic_quotes_10000.xlsx b/testdata/total_data.xlsx similarity index 100% rename from testdata/synthetic_quotes_10000.xlsx rename to testdata/total_data.xlsx