Spaces:
Sleeping
Sleeping
Download src/build_clusters.py from Sujith2121/Semantic-search-cache: direct link, hf CLI and curl.
- Browser
- Download file 638 Bytes
-
https://huggingface.co/spaces/Sujith2121/Semantic-search-cache/resolve/main/src/build_clusters.py
- Command line
-
hf download hf://spaces/Sujith2121/Semantic-search-cache/src/build_clusters.py
-
curl -L -o build_clusters.py https://huggingface.co/spaces/Sujith2121/Semantic-search-cache/resolve/main/src/build_clusters.py
638 Bytes
| from data_loader import load_documents | |
| from preprocess import clean_text | |
| from embedder import embed_documents | |
| from fuzzy_cluster import build_gmm_clusters, save_gmm_model | |
| print("Loading dataset...") | |
| docs, labels = load_documents("data/20_newsgroups") | |
| print("Cleaning documents...") | |
| docs = [clean_text(d) for d in docs] | |
| print("Generating embeddings...") | |
| embeddings = embed_documents(docs) | |
| print("Building fuzzy clusters...") | |
| gmm, cluster_probs = build_gmm_clusters(embeddings) | |
| print("Saving clustering model...") | |
| save_gmm_model(gmm) | |
| print("Cluster probabilities shape:", cluster_probs.shape) | |
| print("Fuzzy clustering completed.") |