[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KF4G3Q3CCQM832FFDGTSKM":3,"skill-same:01M6KF4G3Q3CCQM832FFDGTSKM":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":27,"linkOnly":28,"markdownContent":29,"markdownBody":30,"frontMatter":31,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":37,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":39,"install":40,"resources":53},"01M6KF4G3Q3CCQM832FFDGTSKM","run2_custom_distance_metrics",null,"Implement weighted Euclidean distance metric for DBSCAN with shape parameter","cxcscmu\u002FSkillLearnBench","cxcscmu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142838272?v=4","01M6KCQDFQWPDSN0MKZY96MSQP","01M6KCQDM7G70TKJ28NTSQC0RZ",93,"MIT","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fdbscan-parameter-tuning\u002Frun2_custom_distance_metrics\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26],"metrics","custom","custom distance metrics","run2 custom distance metrics","implement","shape","with","for","metric","2026-11-10 10:12:30",false,"---\nname: run2_custom_distance_metrics\ndescription: Implement weighted Euclidean distance metric for DBSCAN with shape parameter\n---\n\n# Custom Distance Metrics for Shape-Weighted Clustering\n\n## Mathematical Foundation\n\n### Distance Formula\nThe custom weighted Euclidean distance is defined as:\n```\nd(a, b) = sqrt((w * Δx)² + ((2 - w) * Δy)²)\n```\n\nWhere:\n- `w` = shape_weight parameter (controls aspect ratio)\n- `Δx` = x₁ - x₂ (horizontal difference)\n- `Δy` = y₁ - y₂ (vertical difference)\n\n### Shape Weight Interpretation\n- **w = 1.0**: Standard Euclidean distance (equal weighting)\n- **w > 1.0**: Attenuates y-distances (horizontal features more prominent)\n- **w \u003C 1.0**: Attenuates x-distances (vertical features more prominent)\n- **w = 1.9**: Maximum y-attenuation (strongly favors horizontal clustering)\n- **w = 0.9**: Maximum x-attenuation (strongly favors vertical clustering)\n\n### Validation\nEnsure w ∈ [0.9, 1.9] to maintain meaningful distance properties.\n\n## Implementation: Precomputed Distance Matrix\n\nFor DBSCAN with precomputed distances, compute the full pairwise matrix once per image:\n\n```python\nimport numpy as np\nfrom sklearn.cluster import DBSCAN\n\ndef compute_custom_distance_matrix(points, shape_weight):\n    \"\"\"\n    Compute pairwise custom distance matrix efficiently.\n\n    Parameters:\n    - points: (n, 2) array of [x, y] coordinates\n    - shape_weight: float in [0.9, 1.9]\n\n    Returns:\n    - distances: (n, n) symmetric distance matrix\n    \"\"\"\n    n = len(points)\n    distances = np.zeros((n, n))\n\n    # Vectorized computation\n    for i in range(n):\n        dx = points[i, 0] - points[:, 0]\n        dy = points[i, 1] - points[:, 1]\n        distances[i, :] = np.sqrt(\n            (shape_weight * dx)**2 + ((2 - shape_weight) * dy)**2\n        )\n\n    return distances\n\n# Example: Apply to citizen science points for one image\ncitsci_points = np.array([[100, 50], [110, 55], [200, 100]])\nshape_weight = 1.2\ndistance_matrix = compute_custom_distance_matrix(citsci_points, shape_weight)\n\n# Run DBSCAN with precomputed metric\nclusterer = DBSCAN(eps=8, min_samples=5, metric='precomputed')\nlabels = clusterer.fit_predict(distance_matrix)\n```\n\n## Important Design Decisions\n\n### 1. Precomputed vs. Callable Metric\n- **Precomputed**: Compute once, reuse with multiple epsilon values ✓ **Use this**\n- **Callable**: Recompute for each distance query (slower) ✗\n\n### 2. Distance Matrix Properties\n- Symmetric: d(i, j) = d(j, i)\n- Non-negative: d(i, j) ≥ 0\n- Identity: d(i, i) = 0\n- Triangle inequality: may not hold (acceptable for DBSCAN)\n\n### 3. Per-Image Computation\nAlways compute distance matrices **per image**, not globally:\n```python\nfor image_id in unique_images:\n    # Extract image-specific points\n    image_points = citsci_df[citsci_df['file_rad'] == image_id][['x', 'y']].values\n\n    # Compute distance matrix for THIS image only\n    dist_matrix = compute_custom_distance_matrix(image_points, shape_weight)\n\n    # Apply DBSCAN\n    clusterer = DBSCAN(eps=epsilon, min_samples=min_samples, metric='precomputed')\n    labels = clusterer.fit_predict(dist_matrix)\n```\n\n## Edge Cases and Validation\n\n### 1. Empty Image Points\n```python\nif len(image_points) == 0:\n    # No citizen science annotations\n    # Return F1 = 0.0, delta = NaN\n    return 0.0, np.nan\n```\n\n### 2. Single Point\n```python\nif len(image_points) == 1:\n    # Distance matrix is 1x1 all zeros\n    # DBSCAN typically marks as noise unless min_samples=1\n    # Result: no clusters or 1 noise point\n```\n\n### 3. Shape Weight Rounding\n```python\n# Shape weights are rounded to 1 decimal place\nshape_weights = np.round(np.arange(0.9, 2.0, 0.1), 1)\n# [0.9, 1.0, 1.1, 1.2, ..., 1.9]\n```\n\n## Comparison: Custom vs. Standard Distance\n\n```python\n# Standard Euclidean\nd_std = np.sqrt(dx**2 + dy**2)\n\n# Custom (w=1.2, attenuation on y)\nd_custom = np.sqrt((1.2*dx)**2 + (0.8*dy)**2)\n\n# For dx=10, dy=10:\n# d_std = 14.14\n# d_custom = sqrt(144 + 64) = sqrt(208) = 14.42\n# → Custom distance is slightly larger (y-difference less important)\n```\n\n## Testing Sanity Checks\n\n```python\n# Test 1: w=1.0 gives Euclidean\nd_test = compute_custom_distance_matrix(\n    np.array([[0, 0], [3, 4]]),\n    shape_weight=1.0\n)\nassert d_test[0, 1] == 5.0, \"w=1.0 should give standard distance 5\"\n\n# Test 2: Symmetry\nd = compute_custom_distance_matrix(citsci_points, 1.2)\nassert np.allclose(d, d.T), \"Distance matrix must be symmetric\"\n\n# Test 3: Diagonal is zero\nassert np.allclose(np.diag(d), 0), \"Diagonal should be all zeros\"\n```\n\n## Performance Optimization\n\nFor large images (>1000 points), precomputation is still fast:\n- n=1000: ~1 million distance values\n- NumPy vectorized computation: typically \u003C100ms\n- Acceptable for grid search with 847 hyperparameter combinations\n","# Custom Distance Metrics for Shape-Weighted Clustering\n\n## Mathematical Foundation\n\n### Distance Formula\nThe custom weighted Euclidean distance is defined as:\n```\nd(a, b) = sqrt((w * Δx)² + ((2 - w) * Δy)²)\n```\n\nWhere:\n- `w` = shape_weight parameter (controls aspect ratio)\n- `Δx` = x₁ - x₂ (horizontal difference)\n- `Δy` = y₁ - y₂ (vertical difference)\n\n### Shape Weight Interpretation\n- **w = 1.0**: Standard Euclidean distance (equal weighting)\n- **w > 1.0**: Attenuates y-distances (horizontal features more prominent)\n- **w \u003C 1.0**: Attenuates x-distances (vertical features more prominent)\n- **w = 1.9**: Maximum y-attenuation (strongly favors horizontal clustering)\n- **w = 0.9**: Maximum x-attenuation (strongly favors vertical clustering)\n\n### Validation\nEnsure w ∈ [0.9, 1.9] to maintain meaningful distance properties.\n\n## Implementation: Precomputed Distance Matrix\n\nFor DBSCAN with precomputed distances, compute the full pairwise matrix once per image:\n\n```python\nimport numpy as np\nfrom sklearn.cluster import DBSCAN\n\ndef compute_custom_distance_matrix(points, shape_weight):\n    \"\"\"\n    Compute pairwise custom distance matrix efficiently.\n\n    Parameters:\n    - points: (n, 2) array of [x, y] coordinates\n    - shape_weight: float in [0.9, 1.9]\n\n    Returns:\n    - distances: (n, n) symmetric distance matrix\n    \"\"\"\n    n = len(points)\n    distances = np.zeros((n, n))\n\n    # Vectorized computation\n    for i in range(n):\n        dx = points[i, 0] - points[:, 0]\n        dy = points[i, 1] - points[:, 1]\n        distances[i, :] = np.sqrt(\n            (shape_weight * dx)**2 + ((2 - shape_weight) * dy)**2\n        )\n\n    return distances\n\n# Example: Apply to citizen science points for one image\ncitsci_points = np.array([[100, 50], [110, 55], [200, 100]])\nshape_weight = 1.2\ndistance_matrix = compute_custom_distance_matrix(citsci_points, shape_weight)\n\n# Run DBSCAN with precomputed metric\nclusterer = DBSCAN(eps=8, min_samples=5, metric='precomputed')\nlabels = clusterer.fit_predict(distance_matrix)\n```\n\n## Important Design Decisions\n\n### 1. Precomputed vs. Callable Metric\n- **Precomputed**: Compute once, reuse with multiple epsilon values ✓ **Use this**\n- **Callable**: Recompute for each distance query (slower) ✗\n\n### 2. Distance Matrix Properties\n- Symmetric: d(i, j) = d(j, i)\n- Non-negative: d(i, j) ≥ 0\n- Identity: d(i, i) = 0\n- Triangle inequality: may not hold (acceptable for DBSCAN)\n\n### 3. Per-Image Computation\nAlways compute distance matrices **per image**, not globally:\n```python\nfor image_id in unique_images:\n    # Extract image-specific points\n    image_points = citsci_df[citsci_df['file_rad'] == image_id][['x', 'y']].values\n\n    # Compute distance matrix for THIS image only\n    dist_matrix = compute_custom_distance_matrix(image_points, shape_weight)\n\n    # Apply DBSCAN\n    clusterer = DBSCAN(eps=epsilon, min_samples=min_samples, metric='precomputed')\n    labels = clusterer.fit_predict(dist_matrix)\n```\n\n## Edge Cases and Validation\n\n### 1. Empty Image Points\n```python\nif len(image_points) == 0:\n    # No citizen science annotations\n    # Return F1 = 0.0, delta = NaN\n    return 0.0, np.nan\n```\n\n### 2. Single Point\n```python\nif len(image_points) == 1:\n    # Distance matrix is 1x1 all zeros\n    # DBSCAN typically marks as noise unless min_samples=1\n    # Result: no clusters or 1 noise point\n```\n\n### 3. Shape Weight Rounding\n```python\n# Shape weights are rounded to 1 decimal place\nshape_weights = np.round(np.arange(0.9, 2.0, 0.1), 1)\n# [0.9, 1.0, 1.1, 1.2, ..., 1.9]\n```\n\n## Comparison: Custom vs. Standard Distance\n\n```python\n# Standard Euclidean\nd_std = np.sqrt(dx**2 + dy**2)\n\n# Custom (w=1.2, attenuation on y)\nd_custom = np.sqrt((1.2*dx)**2 + (0.8*dy)**2)\n\n# For dx=10, dy=10:\n# d_std = 14.14\n# d_custom = sqrt(144 + 64) = sqrt(208) = 14.42\n# → Custom distance is slightly larger (y-difference less important)\n```\n\n## Testing Sanity Checks\n\n```python\n# Test 1: w=1.0 gives Euclidean\nd_test = compute_custom_distance_matrix(\n    np.array([[0, 0], [3, 4]]),\n    shape_weight=1.0\n)\nassert d_test[0, 1] == 5.0, \"w=1.0 should give standard distance 5\"\n\n# Test 2: Symmetry\nd = compute_custom_distance_matrix(citsci_points, 1.2)\nassert np.allclose(d, d.T), \"Distance matrix must be symmetric\"\n\n# Test 3: Diagonal is zero\nassert np.allclose(np.diag(d), 0), \"Diagonal should be all zeros\"\n```\n\n## Performance Optimization\n\nFor large images (>1000 points), precomputation is still fast:\n- n=1000: ~1 million distance values\n- NumPy vectorized computation: typically \u003C100ms\n- Acceptable for grid search with 847 hyperparameter combinations\n",{"name":5,"description":7},"main","726e1f79b96b0cb3d729d0e55a1c847e0b5353ae","skills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fdbscan-parameter-tuning\u002Frun2_custom_distance_metrics",8,"https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench","https:\u002F\u002Fcxcscmu.github.io\u002FSkillLearnBench","https:\u002F\u002Fgithub.com\u002Fcxcscmu","2026-10-02 22:55:36",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add cxcscmu\u002FSkillLearnBench --skill run2_custom_distance_metrics",{"tool":46,"command":47},"bunx","bunx skills add cxcscmu\u002FSkillLearnBench --skill run2_custom_distance_metrics",{"tool":49,"command":50},"pnpm","pnpm dlx skills add cxcscmu\u002FSkillLearnBench --skill run2_custom_distance_metrics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fdbscan-parameter-tuning\u002Frun2_custom_distance_metrics\u002FSKILL.md",true,[],[55,73,97,115,134,145],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":66,"publishedAt":27},"01M6KM5KH175P5ABP5JMX2SBDQ","object_counter","Count occurrences of an object in the image using computer vision algorithm.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Fvideo-object-counting\u002Fobject_counter\u002FSKILL.md",[61],{"categoryNo":62,"categoryName":63,"taxonomyType":64,"taxonomyTypeDesc":65},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[67,68,69,70,71,72],"object counter","object","vision","computer","Computer Vision","image",{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":82,"publishedAt":27},"01M6KM51TMVXG79MMPCS6Y8G86","travel-planning-workflow","Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Ftravel-planning-workflow\u002FSKILL.md",[79],{"categoryNo":80,"categoryName":81,"taxonomyType":64,"taxonomyTypeDesc":65},"01JBSEEDCAT000000000000023","Skill与智能体开发",[83,84,85,86,87,88,89,90,91,25,92,93,94,95,96],"workflow","planning","planning workflow","travel","travel planning","travel planning workflow","structured","performing","plan","user","it","requirements","essential","itineraries",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":27},"01M6KM4DY820XHS9YTSK5QP5HD","bundled-dataset-search-tool","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.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Fbundled-dataset-search-tool\u002FSKILL.md",[],[104,105,106,107,108,109,110,86,111,112,87,113,25,114,84],"search","tool","dataset","bundled dataset search tool","restaurants","Tools","up","look","flights","you","database",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":27},"01M6KM465BB9PQ0B548HQSVAWZ","glm-output","Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final \u002Froot\u002Fmetrics.json.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-output\u002FSKILL.md",[],[122,123,124,25,125,18,126,127,128,129,130,131,113,132,133],"glm output","output","glm","tasks","json","basics","guidance","matching","verifier","processing","root","calibration",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":141,"publishedAt":27},"01M6KM40KY3QWDW5W97S39R2BC","glm-calibration","Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-calibration\u002FSKILL.md",[140],{"categoryNo":80,"categoryName":81,"taxonomyType":64,"taxonomyTypeDesc":65},[142,133,124,123,128,127,125,143,144,25,26],"glm calibration","setup","companion",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":27},"01M6KM3VHHVSGMGHJQB3PPT6YG","glm-basics","A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-basics\u002FSKILL.md",[],[152,124,127,153,142,133,25,123,154,155,156,157,158,159,125],"glm basics","inspect","relevant","files","good","use","how","Evaluation"]