[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GGEHCJWARN4A6SMY96FGS":3,"skill-same:01M71GGEHCJWARN4A6SMY96FGS":73},{"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":22,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":52,"install":53,"resources":66},"01M71GGEHCJWARN4A6SMY96FGS","umap-learn",null,"UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D\u002F3D visualization, clustering preprocessing (HDBSCAN), supervised\u002Fparametric UMAP, for high-dimensional data.","JSGforever\u002Fskillguard","JSGforever","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85541948?v=4","01M71FQD3E132VMR5F4TAYX3YS","01M71FQD4DYW0XJ4XQ4YQH75Y9",2,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fumap-learn\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000013","分析与可视化","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"learn","umap","umap learn","data","clustering","fast","3D","learning","preprocessing","visualization","dimensionality reduction","manifold","high","for","2d","supervised","parametric","Nonlinear","2026-11-10 10:12:30",false,"---\nname: umap-learn\ndescription: \"UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D\u002F3D visualization, clustering preprocessing (HDBSCAN), supervised\u002Fparametric UMAP, for high-dimensional data.\"\n---\n\n# UMAP-Learn\n\n## Overview\n\nUMAP (Uniform Manifold Approximation and Projection) is a dimensionality reduction technique for visualization and general non-linear dimensionality reduction. Apply this skill for fast, scalable embeddings that preserve local and global structure, supervised learning, and clustering preprocessing.\n\n## Quick Start\n\n### Installation\n\n```bash\nuv pip install umap-learn\n```\n\n### Basic Usage\n\nUMAP follows scikit-learn conventions and can be used as a drop-in replacement for t-SNE or PCA.\n\n```python\nimport umap\nfrom sklearn.preprocessing import StandardScaler\n\n# Prepare data (standardization is essential)\nscaled_data = StandardScaler().fit_transform(data)\n\n# Method 1: Single step (fit and transform)\nembedding = umap.UMAP().fit_transform(scaled_data)\n\n# Method 2: Separate steps (for reusing trained model)\nreducer = umap.UMAP(random_state=42)\nreducer.fit(scaled_data)\nembedding = reducer.embedding_  # Access the trained embedding\n```\n\n**Critical preprocessing requirement:** Always standardize features to comparable scales before applying UMAP to ensure equal weighting across dimensions.\n\n### Typical Workflow\n\n```python\nimport umap\nimport matplotlib.pyplot as plt\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Preprocess data\nscaler = StandardScaler()\nscaled_data = scaler.fit_transform(raw_data)\n\n# 2. Create and fit UMAP\nreducer = umap.UMAP(\n    n_neighbors=15,\n    min_dist=0.1,\n    n_components=2,\n    metric='euclidean',\n    random_state=42\n)\nembedding = reducer.fit_transform(scaled_data)\n\n# 3. Visualize\nplt.scatter(embedding[:, 0], embedding[:, 1], c=labels, cmap='Spectral', s=5)\nplt.colorbar()\nplt.title('UMAP Embedding')\nplt.show()\n```\n\n## Parameter Tuning Guide\n\nUMAP has four primary parameters that control the embedding behavior. Understanding these is crucial for effective usage.\n\n### n_neighbors (default: 15)\n\n**Purpose:** Balances local versus global structure in the embedding.\n\n**How it works:** Controls the size of the local neighborhood UMAP examines when learning manifold structure.\n\n**Effects by value:**\n- **Low values (2-5):** Emphasizes fine local detail but may fragment data into disconnected components\n- **Medium values (15-20):** Balanced view of both local structure and global relationships (recommended starting point)\n- **High values (50-200):** Prioritizes broad topological structure at the expense of fine-grained details\n\n**Recommendation:** Start with 15 and adjust based on results. Increase for more global structure, decrease for more local detail.\n\n### min_dist (default: 0.1)\n\n**Purpose:** Controls how tightly points cluster in the low-dimensional space.\n\n**How it works:** Sets the minimum distance apart that points are allowed to be in the output representation.\n\n**Effects by value:**\n- **Low values (0.0-0.1):** Creates clumped embeddings useful for clustering; reveals fine topological details\n- **High values (0.5-0.99):** Prevents tight packing; emphasizes broad topological preservation over local structure\n\n**Recommendation:** Use 0.0 for clustering applications, 0.1-0.3 for visualization, 0.5+ for loose structure.\n\n### n_components (default: 2)\n\n**Purpose:** Determines the dimensionality of the embedded output space.\n\n**Key feature:** Unlike t-SNE, UMAP scales well in the embedding dimension, enabling use beyond visualization.\n\n**Common uses:**\n- **2-3 dimensions:** Visualization\n- **5-10 dimensions:** Clustering preprocessing (better preserves density than 2D)\n- **10-50 dimensions:** Feature engineering for downstream ML models\n\n**Recommendation:** Use 2 for visualization, 5-10 for clustering, higher for ML pipelines.\n\n### metric (default: 'euclidean')\n\n**Purpose:** Specifies how distance is calculated between input data points.\n\n**Supported metrics:**\n- **Minkowski variants:** euclidean, manhattan, chebyshev\n- **Spatial metrics:** canberra, braycurtis, haversine\n- **Correlation metrics:** cosine, correlation (good for text\u002Fdocument embeddings)\n- **Binary data metrics:** hamming, jaccard, dice, russellrao, kulsinski, rogerstanimoto, sokalmichener, sokalsneath, yule\n- **Custom metrics:** User-defined distance functions via Numba\n\n**Recommendation:** Use euclidean for numeric data, cosine for text\u002Fdocument vectors, hamming for binary data.\n\n### Parameter Tuning Example\n\n```python\n# For visualization with emphasis on local structure\numap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, metric='euclidean')\n\n# For clustering preprocessing\numap.UMAP(n_neighbors=30, min_dist=0.0, n_components=10, metric='euclidean')\n\n# For document embeddings\numap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, metric='cosine')\n\n# For preserving global structure\numap.UMAP(n_neighbors=100, min_dist=0.5, n_components=2, metric='euclidean')\n```\n\n## Supervised and Semi-Supervised Dimension Reduction\n\nUMAP supports incorporating label information to guide the embedding process, enabling class separation while preserving internal structure.\n\n### Supervised UMAP\n\nPass target labels via the `y` parameter when fitting:\n\n```python\n# Supervised dimension reduction\nembedding = umap.UMAP().fit_transform(data, y=labels)\n```\n\n**Key benefits:**\n- Achieves cleanly separated classes\n- Preserves internal structure within each class\n- Maintains global relationships between classes\n\n**When to use:** When you have labeled data and want to separate known classes while keeping meaningful point embeddings.\n\n### Semi-Supervised UMAP\n\nFor partial labels, mark unlabeled points with `-1` following scikit-learn convention:\n\n```python\n# Create semi-supervised labels\nsemi_labels = labels.copy()\nsemi_labels[unlabeled_indices] = -1\n\n# Fit with partial labels\nembedding = umap.UMAP().fit_transform(data, y=semi_labels)\n```\n\n**When to use:** When labeling is expensive or you have more data than labels available.\n\n### Metric Learning with UMAP\n\nTrain a supervised embedding on labeled data, then apply to new unlabeled data:\n\n```python\n# Train on labeled data\nmapper = umap.UMAP().fit(train_data, train_labels)\n\n# Transform unlabeled test data\ntest_embedding = mapper.transform(test_data)\n\n# Use as feature engineering for downstream classifier\nfrom sklearn.svm import SVC\nclf = SVC().fit(mapper.embedding_, train_labels)\npredictions = clf.predict(test_embedding)\n```\n\n**When to use:** For supervised feature engineering in machine learning pipelines.\n\n## UMAP for Clustering\n\nUMAP serves as effective preprocessing for density-based clustering algorithms like HDBSCAN, overcoming the curse of dimensionality.\n\n### Best Practices for Clustering\n\n**Key principle:** Configure UMAP differently for clustering than for visualization.\n\n**Recommended parameters:**\n- **n_neighbors:** Increase to ~30 (default 15 is too local and can create artificial fine-grained clusters)\n- **min_dist:** Set to 0.0 (pack points densely within clusters for clearer boundaries)\n- **n_components:** Use 5-10 dimensions (maintains performance while improving density preservation vs. 2D)\n\n### Clustering Workflow\n\n```python\nimport umap\nimport hdbscan\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Preprocess data\nscaled_data = StandardScaler().fit_transform(data)\n\n# 2. UMAP with clustering-optimized parameters\nreducer = umap.UMAP(\n    n_neighbors=30,\n    min_dist=0.0,\n    n_components=10,  # Higher than 2 for better density preservation\n    metric='euclidean',\n    random_state=42\n)\nembedding = reducer.fit_transform(scaled_data)\n\n# 3. Apply HDBSCAN clustering\nclusterer = hdbscan.HDBSCAN(\n    min_cluster_size=15,\n    min_samples=5,\n    metric='euclidean'\n)\nlabels = clusterer.fit_predict(embedding)\n\n# 4. Evaluate\nfrom sklearn.metrics import adjusted_rand_score\nscore = adjusted_rand_score(true_labels, labels)\nprint(f\"Adjusted Rand Score: {score:.3f}\")\nprint(f\"Number of clusters: {len(set(labels)) - (1 if -1 in labels else 0)}\")\nprint(f\"Noise points: {sum(labels == -1)}\")\n```\n\n### Visualization After Clustering\n\n```python\n# Create 2D embedding for visualization (separate from clustering)\nvis_reducer = umap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, random_state=42)\nvis_embedding = vis_reducer.fit_transform(scaled_data)\n\n# Plot with cluster labels\nimport matplotlib.pyplot as plt\nplt.scatter(vis_embedding[:, 0], vis_embedding[:, 1], c=labels, cmap='Spectral', s=5)\nplt.colorbar()\nplt.title('UMAP Visualization with HDBSCAN Clusters')\nplt.show()\n```\n\n**Important caveat:** UMAP does not completely preserve density and can create artificial cluster divisions. Always validate and explore resulting clusters.\n\n## Transforming New Data\n\nUMAP enables preprocessing of new data through its `transform()` method, allowing trained models to project unseen data into the learned embedding space.\n\n### Basic Transform Usage\n\n```python\n# Train on training data\ntrans = umap.UMAP(n_neighbors=15, random_state=42).fit(X_train)\n\n# Transform test data\ntest_embedding = trans.transform(X_test)\n```\n\n### Integration with Machine Learning Pipelines\n\n```python\nfrom sklearn.svm import SVC\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nimport umap\n\n# Split data\nX_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.2)\n\n# Preprocess\nscaler = StandardScaler()\nX_train_scaled = scaler.fit_transform(X_train)\nX_test_scaled = scaler.transform(X_test)\n\n# Train UMAP\nreducer = umap.UMAP(n_components=10, random_state=42)\nX_train_embedded = reducer.fit_transform(X_train_scaled)\nX_test_embedded = reducer.transform(X_test_scaled)\n\n# Train classifier on embeddings\nclf = SVC()\nclf.fit(X_train_embedded, y_train)\naccuracy = clf.score(X_test_embedded, y_test)\nprint(f\"Test accuracy: {accuracy:.3f}\")\n```\n\n### Important Considerations\n\n**Data consistency:** The transform method assumes the overall distribution in the higher-dimensional space is consistent between training and test data. When this assumption fails, consider using Parametric UMAP instead.\n\n**Performance:** Transform operations are efficient (typically \u003C1 second), though initial calls may be slower due to Numba JIT compilation.\n\n**Scikit-learn compatibility:** UMAP follows standard sklearn conventions and works seamlessly in pipelines:\n\n```python\nfrom sklearn.pipeline import Pipeline\n\npipeline = Pipeline([\n    ('scaler', StandardScaler()),\n    ('umap', umap.UMAP(n_components=10)),\n    ('classifier', SVC())\n])\n\npipeline.fit(X_train, y_train)\npredictions = pipeline.predict(X_test)\n```\n\n## Advanced Features\n\n### Parametric UMAP\n\nParametric UMAP replaces direct embedding optimization with a learned neural network mapping function.\n\n**Key differences from standard UMAP:**\n- Uses TensorFlow\u002FKeras to train encoder networks\n- Enables efficient transformation of new data\n- Supports reconstruction via decoder networks (inverse transform)\n- Allows custom architectures (CNNs for images, RNNs for sequences)\n\n**Installation:**\n```bash\nuv pip install umap-learn[parametric_umap]\n# Requires TensorFlow 2.x\n```\n\n**Basic usage:**\n```python\nfrom umap.parametric_umap import ParametricUMAP\n\n# Default architecture (3-layer 100-neuron fully-connected network)\nembedder = ParametricUMAP()\nembedding = embedder.fit_transform(data)\n\n# Transform new data efficiently\nnew_embedding = embedder.transform(new_data)\n```\n\n**Custom architecture:**\n```python\nimport tensorflow as tf\n\n# Define custom encoder\nencoder = tf.keras.Sequential([\n    tf.keras.layers.InputLayer(input_shape=(input_dim,)),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dense(64, activation='relu'),\n    tf.keras.layers.Dense(2)  # Output dimension\n])\n\nembedder = ParametricUMAP(encoder=encoder, dims=(input_dim,))\nembedding = embedder.fit_transform(data)\n```\n\n**When to use Parametric UMAP:**\n- Need efficient transformation of new data after training\n- Require reconstruction capabilities (inverse transforms)\n- Want to combine UMAP with autoencoders\n- Working with complex data types (images, sequences) benefiting from specialized architectures\n\n**When to use standard UMAP:**\n- Need simplicity and quick prototyping\n- Dataset is small and computational efficiency isn't critical\n- Don't require learned transformations for future data\n\n### Inverse Transforms\n\nInverse transforms enable reconstruction of high-dimensional data from low-dimensional embeddings.\n\n**Basic usage:**\n```python\nreducer = umap.UMAP()\nembedding = reducer.fit_transform(data)\n\n# Reconstruct high-dimensional data from embedding coordinates\nreconstructed = reducer.inverse_transform(embedding)\n```\n\n**Important limitations:**\n- Computationally expensive operation\n- Works poorly outside the convex hull of the embedding\n- Accuracy decreases in regions with gaps between clusters\n\n**Use cases:**\n- Understanding structure of embedded data\n- Visualizing smooth transitions between clusters\n- Exploring interpolations between data points\n- Generating synthetic samples in embedding space\n\n**Example: Exploring embedding space:**\n```python\nimport numpy as np\n\n# Create grid of points in embedding space\nx = np.linspace(embedding[:, 0].min(), embedding[:, 0].max(), 10)\ny = np.linspace(embedding[:, 1].min(), embedding[:, 1].max(), 10)\nxx, yy = np.meshgrid(x, y)\ngrid_points = np.c_[xx.ravel(), yy.ravel()]\n\n# Reconstruct samples from grid\nreconstructed_samples = reducer.inverse_transform(grid_points)\n```\n\n### AlignedUMAP\n\nFor analyzing temporal or related datasets (e.g., time-series experiments, batch data):\n\n```python\nfrom umap import AlignedUMAP\n\n# List of related datasets\ndatasets = [day1_data, day2_data, day3_data]\n\n# Create aligned embeddings\nmapper = AlignedUMAP().fit(datasets)\naligned_embeddings = mapper.embeddings_  # List of embeddings\n```\n\n**When to use:** Comparing embeddings across related datasets while maintaining consistent coordinate systems.\n\n## Reproducibility\n\nTo ensure reproducible results, always set the `random_state` parameter:\n\n```python\nreducer = umap.UMAP(random_state=42)\n```\n\nUMAP uses stochastic optimization, so results will vary slightly between runs without a fixed random state.\n\n## Common Issues and Solutions\n\n**Issue:** Disconnected components or fragmented clusters\n- **Solution:** Increase `n_neighbors` to emphasize more global structure\n\n**Issue:** Clusters too spread out or not well separated\n- **Solution:** Decrease `min_dist` to allow tighter packing\n\n**Issue:** Poor clustering results\n- **Solution:** Use clustering-specific parameters (n_neighbors=30, min_dist=0.0, n_components=5-10)\n\n**Issue:** Transform results differ significantly from training\n- **Solution:** Ensure test data distribution matches training, or use Parametric UMAP\n\n**Issue:** Slow performance on large datasets\n- **Solution:** Set `low_memory=True` (default), or consider dimensionality reduction with PCA first\n\n**Issue:** All points collapsed to single cluster\n- **Solution:** Check data preprocessing (ensure proper scaling), increase `min_dist`\n\n## Resources\n\n### references\u002F\n\nContains detailed API documentation:\n- `api_reference.md`: Complete UMAP class parameters and methods\n\nLoad these references when detailed parameter information or advanced method usage is needed.\n","# UMAP-Learn\n\n## Overview\n\nUMAP (Uniform Manifold Approximation and Projection) is a dimensionality reduction technique for visualization and general non-linear dimensionality reduction. Apply this skill for fast, scalable embeddings that preserve local and global structure, supervised learning, and clustering preprocessing.\n\n## Quick Start\n\n### Installation\n\n```bash\nuv pip install umap-learn\n```\n\n### Basic Usage\n\nUMAP follows scikit-learn conventions and can be used as a drop-in replacement for t-SNE or PCA.\n\n```python\nimport umap\nfrom sklearn.preprocessing import StandardScaler\n\n# Prepare data (standardization is essential)\nscaled_data = StandardScaler().fit_transform(data)\n\n# Method 1: Single step (fit and transform)\nembedding = umap.UMAP().fit_transform(scaled_data)\n\n# Method 2: Separate steps (for reusing trained model)\nreducer = umap.UMAP(random_state=42)\nreducer.fit(scaled_data)\nembedding = reducer.embedding_  # Access the trained embedding\n```\n\n**Critical preprocessing requirement:** Always standardize features to comparable scales before applying UMAP to ensure equal weighting across dimensions.\n\n### Typical Workflow\n\n```python\nimport umap\nimport matplotlib.pyplot as plt\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Preprocess data\nscaler = StandardScaler()\nscaled_data = scaler.fit_transform(raw_data)\n\n# 2. Create and fit UMAP\nreducer = umap.UMAP(\n    n_neighbors=15,\n    min_dist=0.1,\n    n_components=2,\n    metric='euclidean',\n    random_state=42\n)\nembedding = reducer.fit_transform(scaled_data)\n\n# 3. Visualize\nplt.scatter(embedding[:, 0], embedding[:, 1], c=labels, cmap='Spectral', s=5)\nplt.colorbar()\nplt.title('UMAP Embedding')\nplt.show()\n```\n\n## Parameter Tuning Guide\n\nUMAP has four primary parameters that control the embedding behavior. Understanding these is crucial for effective usage.\n\n### n_neighbors (default: 15)\n\n**Purpose:** Balances local versus global structure in the embedding.\n\n**How it works:** Controls the size of the local neighborhood UMAP examines when learning manifold structure.\n\n**Effects by value:**\n- **Low values (2-5):** Emphasizes fine local detail but may fragment data into disconnected components\n- **Medium values (15-20):** Balanced view of both local structure and global relationships (recommended starting point)\n- **High values (50-200):** Prioritizes broad topological structure at the expense of fine-grained details\n\n**Recommendation:** Start with 15 and adjust based on results. Increase for more global structure, decrease for more local detail.\n\n### min_dist (default: 0.1)\n\n**Purpose:** Controls how tightly points cluster in the low-dimensional space.\n\n**How it works:** Sets the minimum distance apart that points are allowed to be in the output representation.\n\n**Effects by value:**\n- **Low values (0.0-0.1):** Creates clumped embeddings useful for clustering; reveals fine topological details\n- **High values (0.5-0.99):** Prevents tight packing; emphasizes broad topological preservation over local structure\n\n**Recommendation:** Use 0.0 for clustering applications, 0.1-0.3 for visualization, 0.5+ for loose structure.\n\n### n_components (default: 2)\n\n**Purpose:** Determines the dimensionality of the embedded output space.\n\n**Key feature:** Unlike t-SNE, UMAP scales well in the embedding dimension, enabling use beyond visualization.\n\n**Common uses:**\n- **2-3 dimensions:** Visualization\n- **5-10 dimensions:** Clustering preprocessing (better preserves density than 2D)\n- **10-50 dimensions:** Feature engineering for downstream ML models\n\n**Recommendation:** Use 2 for visualization, 5-10 for clustering, higher for ML pipelines.\n\n### metric (default: 'euclidean')\n\n**Purpose:** Specifies how distance is calculated between input data points.\n\n**Supported metrics:**\n- **Minkowski variants:** euclidean, manhattan, chebyshev\n- **Spatial metrics:** canberra, braycurtis, haversine\n- **Correlation metrics:** cosine, correlation (good for text\u002Fdocument embeddings)\n- **Binary data metrics:** hamming, jaccard, dice, russellrao, kulsinski, rogerstanimoto, sokalmichener, sokalsneath, yule\n- **Custom metrics:** User-defined distance functions via Numba\n\n**Recommendation:** Use euclidean for numeric data, cosine for text\u002Fdocument vectors, hamming for binary data.\n\n### Parameter Tuning Example\n\n```python\n# For visualization with emphasis on local structure\numap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, metric='euclidean')\n\n# For clustering preprocessing\numap.UMAP(n_neighbors=30, min_dist=0.0, n_components=10, metric='euclidean')\n\n# For document embeddings\numap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, metric='cosine')\n\n# For preserving global structure\numap.UMAP(n_neighbors=100, min_dist=0.5, n_components=2, metric='euclidean')\n```\n\n## Supervised and Semi-Supervised Dimension Reduction\n\nUMAP supports incorporating label information to guide the embedding process, enabling class separation while preserving internal structure.\n\n### Supervised UMAP\n\nPass target labels via the `y` parameter when fitting:\n\n```python\n# Supervised dimension reduction\nembedding = umap.UMAP().fit_transform(data, y=labels)\n```\n\n**Key benefits:**\n- Achieves cleanly separated classes\n- Preserves internal structure within each class\n- Maintains global relationships between classes\n\n**When to use:** When you have labeled data and want to separate known classes while keeping meaningful point embeddings.\n\n### Semi-Supervised UMAP\n\nFor partial labels, mark unlabeled points with `-1` following scikit-learn convention:\n\n```python\n# Create semi-supervised labels\nsemi_labels = labels.copy()\nsemi_labels[unlabeled_indices] = -1\n\n# Fit with partial labels\nembedding = umap.UMAP().fit_transform(data, y=semi_labels)\n```\n\n**When to use:** When labeling is expensive or you have more data than labels available.\n\n### Metric Learning with UMAP\n\nTrain a supervised embedding on labeled data, then apply to new unlabeled data:\n\n```python\n# Train on labeled data\nmapper = umap.UMAP().fit(train_data, train_labels)\n\n# Transform unlabeled test data\ntest_embedding = mapper.transform(test_data)\n\n# Use as feature engineering for downstream classifier\nfrom sklearn.svm import SVC\nclf = SVC().fit(mapper.embedding_, train_labels)\npredictions = clf.predict(test_embedding)\n```\n\n**When to use:** For supervised feature engineering in machine learning pipelines.\n\n## UMAP for Clustering\n\nUMAP serves as effective preprocessing for density-based clustering algorithms like HDBSCAN, overcoming the curse of dimensionality.\n\n### Best Practices for Clustering\n\n**Key principle:** Configure UMAP differently for clustering than for visualization.\n\n**Recommended parameters:**\n- **n_neighbors:** Increase to ~30 (default 15 is too local and can create artificial fine-grained clusters)\n- **min_dist:** Set to 0.0 (pack points densely within clusters for clearer boundaries)\n- **n_components:** Use 5-10 dimensions (maintains performance while improving density preservation vs. 2D)\n\n### Clustering Workflow\n\n```python\nimport umap\nimport hdbscan\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Preprocess data\nscaled_data = StandardScaler().fit_transform(data)\n\n# 2. UMAP with clustering-optimized parameters\nreducer = umap.UMAP(\n    n_neighbors=30,\n    min_dist=0.0,\n    n_components=10,  # Higher than 2 for better density preservation\n    metric='euclidean',\n    random_state=42\n)\nembedding = reducer.fit_transform(scaled_data)\n\n# 3. Apply HDBSCAN clustering\nclusterer = hdbscan.HDBSCAN(\n    min_cluster_size=15,\n    min_samples=5,\n    metric='euclidean'\n)\nlabels = clusterer.fit_predict(embedding)\n\n# 4. Evaluate\nfrom sklearn.metrics import adjusted_rand_score\nscore = adjusted_rand_score(true_labels, labels)\nprint(f\"Adjusted Rand Score: {score:.3f}\")\nprint(f\"Number of clusters: {len(set(labels)) - (1 if -1 in labels else 0)}\")\nprint(f\"Noise points: {sum(labels == -1)}\")\n```\n\n### Visualization After Clustering\n\n```python\n# Create 2D embedding for visualization (separate from clustering)\nvis_reducer = umap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, random_state=42)\nvis_embedding = vis_reducer.fit_transform(scaled_data)\n\n# Plot with cluster labels\nimport matplotlib.pyplot as plt\nplt.scatter(vis_embedding[:, 0], vis_embedding[:, 1], c=labels, cmap='Spectral', s=5)\nplt.colorbar()\nplt.title('UMAP Visualization with HDBSCAN Clusters')\nplt.show()\n```\n\n**Important caveat:** UMAP does not completely preserve density and can create artificial cluster divisions. Always validate and explore resulting clusters.\n\n## Transforming New Data\n\nUMAP enables preprocessing of new data through its `transform()` method, allowing trained models to project unseen data into the learned embedding space.\n\n### Basic Transform Usage\n\n```python\n# Train on training data\ntrans = umap.UMAP(n_neighbors=15, random_state=42).fit(X_train)\n\n# Transform test data\ntest_embedding = trans.transform(X_test)\n```\n\n### Integration with Machine Learning Pipelines\n\n```python\nfrom sklearn.svm import SVC\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nimport umap\n\n# Split data\nX_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.2)\n\n# Preprocess\nscaler = StandardScaler()\nX_train_scaled = scaler.fit_transform(X_train)\nX_test_scaled = scaler.transform(X_test)\n\n# Train UMAP\nreducer = umap.UMAP(n_components=10, random_state=42)\nX_train_embedded = reducer.fit_transform(X_train_scaled)\nX_test_embedded = reducer.transform(X_test_scaled)\n\n# Train classifier on embeddings\nclf = SVC()\nclf.fit(X_train_embedded, y_train)\naccuracy = clf.score(X_test_embedded, y_test)\nprint(f\"Test accuracy: {accuracy:.3f}\")\n```\n\n### Important Considerations\n\n**Data consistency:** The transform method assumes the overall distribution in the higher-dimensional space is consistent between training and test data. When this assumption fails, consider using Parametric UMAP instead.\n\n**Performance:** Transform operations are efficient (typically \u003C1 second), though initial calls may be slower due to Numba JIT compilation.\n\n**Scikit-learn compatibility:** UMAP follows standard sklearn conventions and works seamlessly in pipelines:\n\n```python\nfrom sklearn.pipeline import Pipeline\n\npipeline = Pipeline([\n    ('scaler', StandardScaler()),\n    ('umap', umap.UMAP(n_components=10)),\n    ('classifier', SVC())\n])\n\npipeline.fit(X_train, y_train)\npredictions = pipeline.predict(X_test)\n```\n\n## Advanced Features\n\n### Parametric UMAP\n\nParametric UMAP replaces direct embedding optimization with a learned neural network mapping function.\n\n**Key differences from standard UMAP:**\n- Uses TensorFlow\u002FKeras to train encoder networks\n- Enables efficient transformation of new data\n- Supports reconstruction via decoder networks (inverse transform)\n- Allows custom architectures (CNNs for images, RNNs for sequences)\n\n**Installation:**\n```bash\nuv pip install umap-learn[parametric_umap]\n# Requires TensorFlow 2.x\n```\n\n**Basic usage:**\n```python\nfrom umap.parametric_umap import ParametricUMAP\n\n# Default architecture (3-layer 100-neuron fully-connected network)\nembedder = ParametricUMAP()\nembedding = embedder.fit_transform(data)\n\n# Transform new data efficiently\nnew_embedding = embedder.transform(new_data)\n```\n\n**Custom architecture:**\n```python\nimport tensorflow as tf\n\n# Define custom encoder\nencoder = tf.keras.Sequential([\n    tf.keras.layers.InputLayer(input_shape=(input_dim,)),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dense(64, activation='relu'),\n    tf.keras.layers.Dense(2)  # Output dimension\n])\n\nembedder = ParametricUMAP(encoder=encoder, dims=(input_dim,))\nembedding = embedder.fit_transform(data)\n```\n\n**When to use Parametric UMAP:**\n- Need efficient transformation of new data after training\n- Require reconstruction capabilities (inverse transforms)\n- Want to combine UMAP with autoencoders\n- Working with complex data types (images, sequences) benefiting from specialized architectures\n\n**When to use standard UMAP:**\n- Need simplicity and quick prototyping\n- Dataset is small and computational efficiency isn't critical\n- Don't require learned transformations for future data\n\n### Inverse Transforms\n\nInverse transforms enable reconstruction of high-dimensional data from low-dimensional embeddings.\n\n**Basic usage:**\n```python\nreducer = umap.UMAP()\nembedding = reducer.fit_transform(data)\n\n# Reconstruct high-dimensional data from embedding coordinates\nreconstructed = reducer.inverse_transform(embedding)\n```\n\n**Important limitations:**\n- Computationally expensive operation\n- Works poorly outside the convex hull of the embedding\n- Accuracy decreases in regions with gaps between clusters\n\n**Use cases:**\n- Understanding structure of embedded data\n- Visualizing smooth transitions between clusters\n- Exploring interpolations between data points\n- Generating synthetic samples in embedding space\n\n**Example: Exploring embedding space:**\n```python\nimport numpy as np\n\n# Create grid of points in embedding space\nx = np.linspace(embedding[:, 0].min(), embedding[:, 0].max(), 10)\ny = np.linspace(embedding[:, 1].min(), embedding[:, 1].max(), 10)\nxx, yy = np.meshgrid(x, y)\ngrid_points = np.c_[xx.ravel(), yy.ravel()]\n\n# Reconstruct samples from grid\nreconstructed_samples = reducer.inverse_transform(grid_points)\n```\n\n### AlignedUMAP\n\nFor analyzing temporal or related datasets (e.g., time-series experiments, batch data):\n\n```python\nfrom umap import AlignedUMAP\n\n# List of related datasets\ndatasets = [day1_data, day2_data, day3_data]\n\n# Create aligned embeddings\nmapper = AlignedUMAP().fit(datasets)\naligned_embeddings = mapper.embeddings_  # List of embeddings\n```\n\n**When to use:** Comparing embeddings across related datasets while maintaining consistent coordinate systems.\n\n## Reproducibility\n\nTo ensure reproducible results, always set the `random_state` parameter:\n\n```python\nreducer = umap.UMAP(random_state=42)\n```\n\nUMAP uses stochastic optimization, so results will vary slightly between runs without a fixed random state.\n\n## Common Issues and Solutions\n\n**Issue:** Disconnected components or fragmented clusters\n- **Solution:** Increase `n_neighbors` to emphasize more global structure\n\n**Issue:** Clusters too spread out or not well separated\n- **Solution:** Decrease `min_dist` to allow tighter packing\n\n**Issue:** Poor clustering results\n- **Solution:** Use clustering-specific parameters (n_neighbors=30, min_dist=0.0, n_components=5-10)\n\n**Issue:** Transform results differ significantly from training\n- **Solution:** Ensure test data distribution matches training, or use Parametric UMAP\n\n**Issue:** Slow performance on large datasets\n- **Solution:** Set `low_memory=True` (default), or consider dimensionality reduction with PCA first\n\n**Issue:** All points collapsed to single cluster\n- **Solution:** Check data preprocessing (ensure proper scaling), increase `min_dist`\n\n## Resources\n\n### references\u002F\n\nContains detailed API documentation:\n- `api_reference.md`: Complete UMAP class parameters and methods\n\nLoad these references when detailed parameter information or advanced method usage is needed.\n",{"name":5,"description":7},"main","f2ec4b3b9133d34eeaf9b38e4b0a97e8e5705a7f","benchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fumap-learn",0,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard","https:\u002F\u002Fgithub.com\u002FJSGforever","2026-08-29 18:27:56",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add JSGforever\u002Fskillguard --skill umap-learn",{"tool":59,"command":60},"bunx","bunx skills add JSGforever\u002Fskillguard --skill umap-learn",{"tool":62,"command":63},"pnpm","pnpm dlx skills add JSGforever\u002Fskillguard --skill umap-learn","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fumap-learn\u002FSKILL.md",true,[67],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fapi_reference.md","REFERENCE","参考文档",18966,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fumap-learn\u002Freferences\u002Fapi_reference.md",[74,104,119,146,168,189],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":83,"publishedAt":41},"01M71HY2SNXBA9Q00WZDTZQ31Z","skillguard-codex-scanner","Hybrid deterministic+LLM agent-skill security scanner. Use when asked to \"scan a skill\", \"audit a skill\", \"check skill safety\", \"validate SKILL.md\", \"is this skill safe to install\", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fsrc\u002Fskillguard\u002Fstatic_scanner\u002Fskillguard-codex-scanner\u002FSKILL.md",[80],{"categoryNo":81,"categoryName":82,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103],"scanner","skillguard codex scanner","skillguard","codex","chain","skill security","security-review","review report","structural","secret","prompt injection","security scanner","when","review","malicious","permissions","exposure","audit","scripts","safe",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":116,"publishedAt":41},"01M71HY0SPKTT3S27BC2HPAC5M","data-exfiltrator","Analyzes data files","MIT","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Fsmoke-one-skill\u002Fasset1__cisco-ai-defense--data-exfiltrator\u002FSKILL.md",[111],{"categoryNo":112,"categoryName":113,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[26,117,118],"data exfiltrator","files",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":41},"01M71HXVS9EMN44BGDW215FZ72","real-time-collaboration-engine","Build real-time collaborative editing with WebSockets, OT\u002FCRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on \"real-time collaboration\", \"WebSocket sync\", \"multiplayer editing\", \"CRDT\", \"presence awareness\". NOT for simple chat, request-response APIs, or single-user apps.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--real-time-collaboration-engine\u002FSKILL.md",[],[126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145],"time","real time collaboration engine","real time collaboration","collaboration","engine","real time","Video","reliability","video editing","performance","conflict resolution","presence","access","apps","updates","Bash","activate","optimizer","react","streaming",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":155,"publishedAt":41},"01M71HXP6CTY4KFN0QVMMN0V7J","react-performance-optimizer","Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on \"React performance\", \"slow render\", \"useMemo\", \"bundle size\", \"virtualization\". NOT for backend optimization, non-React frameworks, or premature optimization.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--react-performance-optimizer\u002FSKILL.md",[152],{"categoryNo":153,"categoryName":154,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000009","前端开发",[135,156,143,144,157,158,159,160,161,162,126,163,164,139,141,165,142,145,166,167],"react performance optimizer","react performance","performance optimizer","app","nextjs","expert","re","render","2025","code","router","strategies",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":175,"publishedAt":41},"01M71HXH7QXSQB4QTDZ7SP7YXQ","llm-streaming-response-handler","Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI\u002FAnthropic\u002FClaude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on \"LLM streaming\", \"SSE\", \"token stream\", \"chat UI\", \"real-time AI\". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--llm-streaming-response-handler\u002FSKILL.md",[174],{"categoryNo":153,"categoryName":154,"taxonomyType":20,"taxonomyTypeDesc":21},[176,145,177,178,179,180,135,126,181,182,183,141,142,143,184,144,185,186,187,188],"llm streaming response handler","handler","error","processing","retry","chat ui","error recovery","critical","batch","display","text","server","read",{"skillNo":190,"name":191,"nameZh":6,"description":192,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":193,"categories":194,"keywords":202,"publishedAt":41},"01M71HXCB0E1YRKYW1Y8T0Y106","github-actions-pipeline-builder","Build production CI\u002FCD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on \"GitHub Actions\", \"CI\u002FCD\", \"workflow\", \"deployment pipeline\", \"automated testing\". NOT for Jenkins\u002FCircleCI, manual deployments, or non-GitHub repositories.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--github-actions-pipeline-builder\u002FSKILL.md",[195,198,201],{"categoryNo":196,"categoryName":197,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":199,"categoryName":200,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000011","运维与部署",{"categoryNo":81,"categoryName":82,"taxonomyType":20,"taxonomyTypeDesc":21},[203,204,205,206,207,208,209,133,161,210,211,212,142,167,213,188,214,215,216,217],"github actions pipeline builder","actions","github actions","pipeline builder","github","builder","pipeline","testing","ci","workflows","run","release","write","edit","git"]