fix(spatial): 提取器正负召回分开报,凭证分母只含真值为真的样本
This commit is contained in:
1 parent
bf443062b4
commit
3a5bc1dbcd
1 file changed
+34
-17
+34
-17
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user