HierarchicalClustering¶
- class HierarchicalClustering(distance: etna.clustering.distances.base.Distance)[source]¶
Bases:
etna.clustering.base.Clustering
Base class for hierarchical clustering.
Init HierarchicalClustering.
- Inherited-members
- Parameters
distance (etna.clustering.distances.base.Distance) –
Methods
build_clustering_algo
([n_clusters, linkage])Build clustering algo (see
sklearn.cluster.AgglomerativeClustering
) with given params.Compute distance matrix with given ts and distance.
Fit clustering algorithm and predict clusters according to distance matrix build.
get_centroids
(**averaging_kwargs)Get centroids of clusters.
set_params
(**params)Return new object instance with modified parameters.
to_dict
()Collect all information about etna object in dict.
- build_clustering_algo(n_clusters: int = 30, linkage: Union[str, etna.clustering.hierarchical.base.ClusteringLinkageMode] = ClusteringLinkageMode.average, **clustering_algo_params)[source]¶
Build clustering algo (see
sklearn.cluster.AgglomerativeClustering
) with given params.- Parameters
n_clusters (int) – number of clusters to build
linkage (Union[str, etna.clustering.hierarchical.base.ClusteringLinkageMode]) – rule for distance computation for new clusters, allowed “ward”, “single”, “average”, “maximum”, “complete”
Notes
Note that it will reset previous results of clustering in case of reinit algo.
- build_distance_matrix(ts: etna.datasets.tsdataset.TSDataset)[source]¶
Compute distance matrix with given ts and distance.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – TSDataset with series to build distance matrix
distance – instance if distance to compute matrix