| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/hierarchical_clustering.rst.txt |
.. _library_hierarchical_clustering:
hierarchical_clusteringHierarchical clusterer. Supports continuous attributes only. It builds the full bottom-up agglomerative_clusterer hierarchy and derives the requested partition by cutting the learned dendrogram at the largest remaining merge distances.
The library implements the clusterer_protocol defined in the
clustering_protocols library. It provides predicates for learning a
full agglomerative_clusterer hierarchy from a dataset, deriving a
k-cluster cut for prediction, and exporting the learned clusterer as
a list of predicate clauses or to a file.
Datasets are represented as objects implementing the
clustering_dataset_protocol protocol from the
clustering_protocols library.
Open the `../../apis/library_index.html#hierarchical_clustering <../../apis/library_index.html#hierarchical_clustering>`__ link in a web browser.
To load this library, load the loader.lgt file:
::
| ?- logtalk_load(hierarchical_clustering(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(hierarchical_clustering(tester)).
To run the performance benchmark suite, load the
tester_performance.lgt file:
::
| ?- logtalk_load(hierarchical_clustering(tester_performance)).
k
clusters by repeatedly splitting the highest remaining merge.single, complete, and
average linkage.single, complete, and average linkage instead of
recomputing all member-pair distances after every merge.k using cut/3 without retraining.The following options can be passed to the learn/3 predicate:
k(K): Number of clusters to retain after cutting the learned
hierarchy. Default is 2.linkage(Linkage): Linkage strategy to use. Options: single,
complete, or average (default).distance_metric(Metric): Distance metric to use. Options:
euclidean (default) or manhattan.feature_scaling(FeatureScaling): Whether to standardize continuous
attributes before clustering. Options: on (default) or off.The learned clusterer is represented as a compound term with the functor chosen by the user when exporting the clusterer and arity 5. For example:
::
hierarchical_clustering_clusterer(Encoders, hierarchy(RootState, MergeRecords, Dendrogram), Clusters, Prototypes, Diagnostics)
Where:
Encoders: List of continuous attribute encoders storing attribute
name, mean, and scale.hierarchy(RootState, MergeRecords, Dendrogram): Reusable hierarchy
state. RootState and MergeRecords are used internally by
cut/3, and Dendrogram is the learned merge tree represented
with leaf(Id) and merge(Left, Right, Distance, Size) terms.Clusters: List of cluster(Id, Points) terms for the selected
k-cluster cut.Prototypes: List of average vectors kept for display and export
metadata.Diagnostics: Diagnostics metadata including the effective training
options used to learn the clusterer.cut(+Clusterer, +K, -RecutClusterer): Reuses the learned hierarchy
to derive a new K-cluster cut without retraining.The diagnostics/2 predicate returns metadata terms including:
model(hierarchical_clustering)cluster_count(Count)prototype_count(Count)training_example_count(Count)merge_count(Count)dendrogram_height(Height)heap_rebuild_count(Count)scan_fallback_count(Count)maximum_heap_size(Size)tie_breaking(node_id_order)options(Options)