用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill run2-matching-metrics命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | run2_matching-metrics |
| description | Greedy point matching and calculation of F1 score and average distance (delta). |
Detailed implementation of the matching process and metric calculations for image-based clustering.
from scipy.spatial.distance import cdist
import numpy as np
def match_and_evaluate(predicted, expert, max_dist=100):
"""
Match predicted centroids to expert points and compute metrics.
"""
if len(predicted) == 0:
return 0.0, np.nan
if len(expert) == 0:
return 0.0, np.nan
# Greedy matching based on Euclidean distance
dists = cdist(predicted, expert, metric='euclidean')
# Flatten and sort pairs by distance
pairs = []
for i in range(dists.shape[0]):
for j in range(dists.shape[1]):
if dists[i, j] <= max_dist:
pairs.append((dists[i, j], i, j))
pairs.sort()
matched_p = set()
matched_e = set()
match_distances = []
for d, i, j in pairs:
if i not in matched_p and j not in matched_e:
matched_p.add(i)
matched_e.add(j)
match_distances.append(d)
tp = len(match_distances)
fp = len(predicted) - tp
fn = len(expert) - tp
precision = tp / (tp + fp) if (tp + fp) > 0 else 0
recall = tp / (tp + fn) if (tp + fn) > 0 else 0
f1 = 2 * precision * recall / (precision + recall) if (precision + recall) > 0 else 0
delta = np.mean(match_distances) if match_distances else np.nan
return f1, delta