MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / global_cluster_embeddings

Function global_cluster_embeddings

_cluster_utils.py:179–190  ·  view source on GitHub ↗
(
    embeddings: np.ndarray,
    dim: int,
    n_neighbors: int = 15,
    metric: str = "cosine",
)

Source from the content-addressed store, hash-verified

177 return list_data
178
179def global_cluster_embeddings(
180 embeddings: np.ndarray,
181 dim: int,
182 n_neighbors: int = 15,
183 metric: str = "cosine",
184) -> np.ndarray:
185 if n_neighbors is None:
186 n_neighbors = int((len(embeddings) - 1) ** 0.5)
187 reduced_embeddings = umap.UMAP(
188 n_neighbors=n_neighbors, n_components=dim, metric=metric
189 ).fit_transform(embeddings)
190 return reduced_embeddings
191
192
193def local_cluster_embeddings(

Callers 1

perform_clusteringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected