一键导入
greedy-bipartite-matching
Implement greedy bipartite matching for pairing cluster centroids with expert annotations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement greedy bipartite matching for pairing cluster centroids with expert annotations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
This skill includes search capability in 13F, such as fuzzy search a fund information using possibly inaccurate name, or fuzzy search a stock cusip info using its name.
A comprehensive PDF toolkit for advanced data extraction and document analysis. Beyond text and table extraction, this tool is optimized for visual layout reasoning: it can map graphical elements to coordinates (such as determining appointment times based on their position on a calendar timeline) and identify color-coded features (e.g., distinguishing high-priority blocks from flexible blue-colored entries). Use this skill when the task requires interpreting schedule layouts, calculating durations from visual spans, or resolving scheduling conflicts based on the spatial and color properties of a PDF document.
Build deterministic, verifiable data visualizations with D3.js (v6). Generate standalone HTML/SVG (and optional PNG) from local data files without external network dependencies. Use when tasks require charts, plots, axes/scales, legends, tooltips, or data-driven SVG output.
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
| name | greedy-bipartite-matching |
| description | Implement greedy bipartite matching for pairing cluster centroids with expert annotations. |
Greedy matching finds pairs between two sets of points by iteratively selecting the closest unmatched pair until no more matches are possible below a distance threshold.
import numpy as np
def greedy_match(centroids, expert_points, max_distance=100):
"""
Match centroids to expert points using greedy algorithm.
Args:
centroids: (n, 2) array of cluster centroids
expert_points: (m, 2) array of expert annotations
max_distance: Maximum distance for a valid match
Returns:
matched_pairs: List of (centroid_idx, expert_idx, distance) tuples
"""
centroids = np.asarray(centroids)
expert_points = np.asarray(expert_points)
if len(centroids) == 0 or len(expert_points) == 0:
return []
# Compute Euclidean distances (always standard Euclidean for matching)
distances = np.linalg.norm(
centroids[:, np.newaxis, :] - expert_points[np.newaxis, :, :],
axis=2
)
matched_pairs = []
unmatched_centroids = set(range(len(centroids)))
unmatched_experts = set(range(len(expert_points)))
while unmatched_centroids and unmatched_experts:
# Find closest unmatched pair
min_dist = np.inf
best_c_idx = None
best_e_idx = None
for c_idx in unmatched_centroids:
for e_idx in unmatched_experts:
dist = distances[c_idx, e_idx]
if dist < min_dist:
min_dist = dist
best_c_idx = c_idx
best_e_idx = e_idx
# If distance exceeds threshold, stop
if min_dist > max_distance:
break
# Record match and remove from unmatched sets
matched_pairs.append((best_c_idx, best_e_idx, min_dist))
unmatched_centroids.remove(best_c_idx)
unmatched_experts.remove(best_e_idx)
return matched_pairs
def compute_f1_and_delta(matched_pairs, num_centroids, num_expert_points):
"""
Compute F1 score and average delta from matched pairs.
Returns:
f1: Precision-recall harmonic mean
avg_delta: Average distance of matched pairs
"""
if len(matched_pairs) == 0:
return 0.0, np.nan
# True positives = number of matches
tp = len(matched_pairs)
# False positives = unmatched centroids
fp = num_centroids - tp
# False negatives = unmatched expert points
fn = num_expert_points - tp
# Precision and recall
precision = tp / (tp + fp) if (tp + fp) > 0 else 0.0
recall = tp / (tp + fn) if (tp + fn) > 0 else 0.0
# F1 score
f1 = 2 * (precision * recall) / (precision + recall) if (precision + recall) > 0 else 0.0
# Average delta (distance)
avg_delta = np.mean([dist for _, _, dist in matched_pairs])
return f1, avg_delta