LabelPropagationClustering¶
Overview¶
The LabelPropagationClustering class is designed to detect communities in a graph using the Label Propagation algorithm. It extends the GraphClustering class.
Arguments¶
text(str): The input text containing sentences to be clustered.resolution(float): The resolution parameter for the Label Propagation algorithm.threshold(float): The similarity threshold for connecting nodes in the graph.
Example Usage¶
Here's an example demonstrating how to use the LabelPropagationClustering class:
from euler.clustering import LabelPropagationClustering
text = """
Your text data here
"""
clustering = LabelPropagationClustering(text, resolution=1.0, threshold=0.5)
clusters = clustering.get_clusters()
print(clusters)
Functions¶
encode_sentences¶
Encodes sentences into embeddings using BERT.
build_graph¶
Builds the graph using sentence embeddings and cosine similarity.
detect_communities¶
Detects communities in the graph using the Label Propagation algorithm.
get_clusters¶
Returns the clusters detected in the graph as a dictionary.