Observed since 20 Oct, 18:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
ACLOSE- Automatic Clustering and Labeling Of Semantic Embeddings
ACLOSE is a powerful machine learning library that automates the discovery, labeling, and visualization of topics within text data. It combines cutting-edge dimensionality reduction, clustering, and large language models to transform raw embeddings into meaningful, labeled topics with minimal code.
Think of it as automatic topic discovery without the headaches.

ACLOSE offers a streamlined, three-step process:
No more guessing at parameters or manually interpreting cluster contents!
Before installing, make sure you have a C++ compiler:
sudo apt-get install build-essentialxcode-select --installpip install aclose
import pandas as pd
from aclose import run_clustering
# Example DataFrame with embeddings
df = pd.DataFrame({
"content": ["Text document 1", "Text document 2", "Text document 3"],
"embedding_vector": [[0.1, 0.2, ...], [0.3, 0.4, ...], [0.5, 0.6, ...]]
})
# Run clustering with optimized parameters
result = run_clustering(df)
# Get the clustered dataframe
clustered_df = result["clustered_df"]
from aclose import add_labels
# Generate semantic topic labels for clusters
label_result = add_labels(
cluster_df=clustered_df,
data_description="Dataset of scientific paper abstracts",
llm_model="o1-mini" # Use OpenAI models
)
# Get labeled dataframe and mapping
labeled_df = label_result["dataframe"]
topic_mapping = label_result["labels_dict"]
print(topic_mapping) # {0: "Machine Learning Applications", 1: "Climate Change Research", ...}
from aclose import silhouette_fig, scatter_fig, bars_fig
# Generate and display three complementary visualizations
silhouette_fig(labeled_df).show() # Assess cluster quality
scatter_fig(labeled_df, content_col_name="content").show() # Explore semantic space
bars_fig(labeled_df).show() # View topic distribution
ACLOSE provides three powerful visualizations to help you understand your data:
Explore the semantic relationships between your documents in an interactive 3D or 2D visualization. Each point represents a document, color-coded by cluster, with topics labeled at cluster centers.

See the relative sizes of each topic in your dataset with a clear, color-coded bar chart. Quickly identify dominant themes and niche topics.

Evaluate the quality of your clustering with a silhouette plot. Higher values indicate better-defined clusters, helping you assess the reliability of your topics.

Instantly discover the main themes in your text corpus without manual annotation or parameter tuning.
from aclose import run_clustering, add_labels, scatter_fig
result = run_clustering(df)
labeled = add_labels(result["clustered_df"])
scatter_fig(labeled["dataframe"]).show()
Try different dimensionality settings before committing to expensive labeling operations:
# Try 2D clustering (good for visualization)
clustering_2d = run_clustering(df, dims=2)
# Try 3D clustering (better balance of viz & quality)
clustering_3d = run_clustering(df, dims=3)
# Let the algorithm find optimal dimensions
clustering_nd = run_clustering(df, dims=None)
# Compare metrics
print(clustering_2d["metrics_dict"])
print(clustering_3d["metrics_dict"])
print(clustering_nd["metrics_dict"])
# Choose the best and label it
best_clustering = clustering_3d # based on metrics
labeled = add_labels(best_clustering["clustered_df"])
Reuse trained models to classify new data and monitor distribution drift:
# Train initial models
clustering = run_clustering(training_df)
labeled = add_labels(clustering["clustered_df"])
# Extract models for reuse
umap_model = clustering["umap_model"]
hdbscan_model = clustering["hdbscan_model"]
topic_mapping = labeled["labels_dict"]
# Apply to new data
new_embeddings = get_embeddings(new_df)
reduced_vectors = umap_model.transform(new_embeddings)
new_labels, probabilities = hdbscan.approximate_predict(hdbscan_model, reduced_vectors)
new_df["topic"] = [topic_mapping.get(label, "Unknown") for label in new_labels]
ACLOSE isn't just a simple pipeline—it employs sophisticated techniques to produce high-quality topic clusters:
For detailed documentation, including guidance on all hyperparameters, see DOCUMENTATION.md. Alternatively, if you're in a hurry, you can chat with the code using a (gimmicky) custom GPT.
run_clusteringPerforms optimized clustering on embeddings and returns models and results.
result = run_clustering(
filtered_df, # DataFrame with embedding_vector column
min_clusters=3, # Minimum acceptable clusters
max_clusters=25, # Maximum acceptable clusters
dims=3, # Target dimensionality (None to optimize)
target_pca_evr=0.9, # PCA explained variance ratio target
hdbscan_outlier_threshold=10, # Percentile for core point detection
# Many more configurable parameters...
)
Returns a dictionary with:
clustered_df: DataFrame with cluster assignments and metadataumap_model: Fitted UMAP model for reusehdbscan_model: Fitted HDBSCAN modelpca_model: Fitted PCA model (if used)metrics_dict: Clustering quality metricsbranch_detector: Branch detector (if used)add_labelsGenerates semantic topic labels for clusters using LLMs.
result = add_labels(
cluster_df, # DataFrame from run_clustering
llm_model="o1-mini", # LLM to use for labeling
language="english", # Output language
data_description="Scientific papers", # Context for the LLM
content_col_name="abstract", # Column with text content
# More configuration options...
)
Returns a dictionary with:
dataframe: Original DataFrame with added 'topic' columnlabels_dict: Mapping from cluster_id to topic labelsilhouette_fig(df): Creates a silhouette plot for evaluating cluster qualityscatter_fig(df): Creates a 2D/3D scatter plot of document clustersbars_fig(df): Creates a bar chart of topic distributionWe welcome contributions! See CONTRIBUTING.md for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)Distributed under the MIT License. See LICENSE for more information.
Here is a list of features that we are planning to add in the future. If you would like to take up any of these features, please create an issue and assign it to yourself:
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 7 Mar 2025 | 14 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:69850c2522317241400c875b5fc86701487a42a746d10d95026a9181fe20671a