HierarchicalClustering {less}R Documentation

Hierarchical Clustering

Description

Wrapper R6 Class of stats::hclust function that can be used for LESSRegressor and LESSClassifier

Value

R6 Class of HierarchicalClustering

Super class

less::BaseEstimator -> HierarchicalClustering

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of R6 Class of HierarchicalClustering

Usage
HierarchicalClustering$new(linkage = "ward.D2", n_clusters = 8)
Arguments
linkage

the agglomeration method to be used. This should be (an unambiguous abbreviation of) one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC) (defaults to ward.D2).

n_clusters

the number of clusters (defaults to 8).

Examples
hc <- HierarchicalClustering$new()
hc <- HierarchicalClustering$new(n_clusters = 10)
hc <- HierarchicalClustering$new(n_clusters = 10, linkage = "complete")

Method fit()

Perform hierarchical clustering on a data matrix.

Usage
HierarchicalClustering$fit(X)
Arguments
X

numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns).

Returns

Fitted R6 class of HierarchicalClustering() that has 'labels' attribute

Examples
data(abalone)
hc <- HierarchicalClustering$new()
hc$fit(abalone[1:100,])

Method get_cluster_centers()

Auxiliary function returning the cluster centers

Usage
HierarchicalClustering$get_cluster_centers()
Examples
print(hc$get_cluster_centers())

Method get_labels()

Auxiliary function returning a vector of integers (from 1:k) indicating the cluster to which each point is allocated.

Usage
HierarchicalClustering$get_labels()
Examples
print(hc$get_labels())

Method clone()

The objects of this class are cloneable with this method.

Usage
HierarchicalClustering$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

stats::hclust()

Examples


## ------------------------------------------------
## Method `HierarchicalClustering$new`
## ------------------------------------------------

hc <- HierarchicalClustering$new()
hc <- HierarchicalClustering$new(n_clusters = 10)
hc <- HierarchicalClustering$new(n_clusters = 10, linkage = "complete")

## ------------------------------------------------
## Method `HierarchicalClustering$fit`
## ------------------------------------------------

data(abalone)
hc <- HierarchicalClustering$new()
hc$fit(abalone[1:100,])

## ------------------------------------------------
## Method `HierarchicalClustering$get_cluster_centers`
## ------------------------------------------------

print(hc$get_cluster_centers())

## ------------------------------------------------
## Method `HierarchicalClustering$get_labels`
## ------------------------------------------------

print(hc$get_labels())

[Package less version 0.1.0 Index]