From 3a5bc1dbcd46907d9480ca299527641699eeca36 Mon Sep 17 00:00:00 2001 From: x Date: Thu, 3 Dec 2026 22:19:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(spatial):=20=E6=8F=90=E5=8F=96=E5=99=A8?= =?UTF-8?q?=E6=AD=A3=E8=B4=9F=E5=8F=AC=E5=9B=9E=E5=88=86=E5=BC=80=E6=8A=A5?= =?UTF-8?q?=EF=BC=8C=E5=87=AD=E8=AF=81=E5=88=86=E6=AF=8D=E5=8F=AA=E5=90=AB?= =?UTF-8?q?=E7=9C=9F=E5=80=BC=E4=B8=BA=E7=9C=9F=E7=9A=84=E6=A0=B7=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spatial/extract.py | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/spatial/extract.py b/spatial/extract.py index 1bbf052..af03aab 100644 --- a/spatial/extract.py +++ b/spatial/extract.py @@ -128,12 +128,18 @@ def _answer(sc, edges) -> bool: def report(n: int = 32) -> None: - print(f"{'family':11s} {'真边':>5s} {'提取':>5s} {'答案一致':>7s} {'凭证有效':>7s} " - f"{'最小间隙':>7s}") - print("-" * 56) + """Positive and negative recall are reported apart on purpose. + + A graph with no relations answers "false" to every query, so a single + "agreement" number would hand it the whole negative class for free. What M2 + needs to know is whether geometry alone can ever establish the positive. + """ + print(f"{'family':11s} {'真边':>5s} {'提取':>5s} {'真阳率':>6s} {'真阴率':>6s} " + f"{'凭证':>5s} {'余隙':>5s}") + print("-" * 54) for fam in generator.FAMILIES: - same = valid = total = 0 - got = truth = 0 + n_true = n_false = hit_true = hit_false = cert_ok = 0 + got = truth = total = 0 gap = np.inf for i in range(n): sc = generator.make(fam, seed=3, index=i) @@ -143,22 +149,33 @@ def report(n: int = 32) -> None: boxes = [e.attrs["box"] for e in sc.obs.entities if e.attrs.get("box")] for p in range(len(boxes)): for q in range(p + 1, len(boxes)): - gap = min(gap, surface_gap(boxes[p], boxes[q])) + g = surface_gap(boxes[p], boxes[q]) + if g > 0: + gap = min(gap, g) # clearance, not the touching pairs total += 1 truth += len(sc.obs.edges) got += len(edges) - same += int(_answer(sc, edges) == _answer(sc, sc.obs.edges)) - ev = checker.evidence_for(FullState(entities=list(sc.obs.entities), - edges=edges), sc.query) - if sc.label.answer == "true": - valid += int(bool(ev) and checker.validate_evidence( - FullState(entities=list(sc.obs.entities), edges=edges), sc.query, ev)) + world = FullState(entities=list(sc.obs.entities), edges=edges) + if _answer(sc, sc.obs.edges): + n_true += 1 + hit_true += int(bool(_answer(sc, edges))) + ev = checker.evidence_for(world, sc.query) + cert_ok += int(bool(ev) and checker.validate_evidence(world, sc.query, ev)) + else: + n_false += 1 + hit_false += int(not _answer(sc, edges)) + rec = f"{hit_true / n_true:6.2f}" if n_true else " —" + neg = f"{hit_false / n_false:6.2f}" if n_false else " —" + cert = f"{cert_ok / n_true:5.2f}" if n_true else " —" g = "—" if not np.isfinite(gap) else f"{gap:.0f}" - print(f"{fam:11s} {truth/max(1,total):5.1f} {got/max(1,total):5.1f} " - f"{same/max(1,total):7.2f} {valid/max(1,total):7.2f} {g:>7s}") - print("\n真边=观测里的关系数,提取=只看几何能得到的边数(容差 0.5,单位 0.25mm)") - print("答案一致=去掉全部元数据关系后用几何图重算,与真值同解的比例") - print("最小间隙=该族任意两个零件表面的最近距离(0.25mm 制),说明容差有没有被真正考验") + print(f"{fam:11s} {truth / max(1, total):5.1f} {got / max(1, total):5.1f} " + f"{rec} {neg} {cert} {g:>5s}") + print() + print("真边 = 观测里的关系数;提取 = 只看几何能得到的边数(容差 0.5,单位 0.25mm)") + print("真阳率 = 真值为真的样本里几何图也判真的比例,即几何能不能自己证明") + print("真阴率 = 真值为假的样本里几何图也判假的比例,零关系的图靠这一列刷分") + print("凭证 = 真值为真的样本里,几何图给出的凭证能通过检查的比例") + print("余隙 = 互不接触的零件表面之间的最小距离,说明容差有没有被真正考验") def main(argv=None) -> int: