scatcluster.analysis.dendrogram¶
Dendrogram analysis module.
Classes¶
Functions¶
|
Get dendrogram list of leaves coordinates and colors. |
|
Get cluster predection for each sample. |
|
Generate a dendrogram plot and return the cluster predictions. |
|
Generates a dendrogram plot and visualizes cluster properties for a given linkage matrix and times. |
Module Contents¶
- scatcluster.analysis.dendrogram.get_leaves(dendrogram_info, ax)[source]¶
Get dendrogram list of leaves coordinates and colors.
- Parameters:
dendrogram_info (dict) – Output of the scipy.hierarchy.dendrogram function.
ax (plt.Axes) – The axes to draw the dendrogram into.
- Returns:
leaves_coordinates (array-like) – The x coordinates of each leave.
leaves_population_size (array-like) – The population size of each leave.
- scatcluster.analysis.dendrogram.get_prediction(linkage, population_size)[source]¶
Get cluster predection for each sample.
The dendrogram (or linkage) matrix sorts the samples per catergory. We revert that back to their correct time coordinate. Note: the clusters are labeled from 1 to n_clusters.
- Parameters:
linkage (np.ndarray) – Output of the linkage function.
population_size (list) – The size of every cluster
- scatcluster.analysis.dendrogram.show_dendrogram(linkage, ax=None, depth=30)[source]¶
Generate a dendrogram plot and return the cluster predictions.
- Parameters:
linkage (np.ndarray) – The linkage matrix.
ax (matplotlib.axes.Axes, optional) – The axes to plot the dendrogram on. Defaults to None.
depth (int, optional) – The depth of the dendrogram. Defaults to 30.
- Returns:
The cluster predictions for each sample.
- Return type:
np.ndarray
- scatcluster.analysis.dendrogram.dendrogram(linkage, times, n_clusters, n_cal_bins=150)[source]¶
Generates a dendrogram plot and visualizes cluster properties for a given linkage matrix and times.
- Parameters:
linkage (numpy.ndarray) – The linkage matrix representing the hierarchical clustering.
times (numpy.ndarray) – The array of times associated with each data point.
n_clusters (int) – The number of clusters to show in the dendrogram.
n_cal_bins (int, optional) – The number of calendar bins to use for calendar occurrences. Defaults to 150.
- Returns:
A tuple containing the figure object and the predictions made by the dendrogram.
- Return type:
- class scatcluster.analysis.dendrogram.Dendrogram[source]¶
- process_dendrogram_linkage(**kwargs) None[source]¶
Process the full linkage for the Dendrogram. This is managed via dendrogram_method. Any additional parameters apart from ‘method’ can be supplied via kwargs
- preload_linkage() None[source]¶
Load the linkage for the Dendrogram.
This function loads the linkage for the Dendrogram from a file. The file path is constructed using the attributes data_network, data_station, data_location, network_name, and ica_number_components of the instance. The file path is constructed using the data_savepath attribute of the instance.
- single_dendrogram(n_clusters: int, print_predictions: bool = True) numpy.ndarray | None[source]¶
Visualise a single Dendrogram based on n_cluster
- range_dendrograms(dendrogram_start: int = 4, dendrogram_end: int = 20) None[source]¶
Visualise a range of Dendrograms based on dendrogram_start and dendrogram_end
- preload_dendrogram_linkage(n_clusters: int) None[source]¶
Preload Dendrogram linkage based on n_clusters.
- Parameters:
n_clusters (int) – Number of clusters
Sets the axes sharing properties for a given set of axes.
- Parameters:
axs (numpy.ndarray) – The array of axes to set the sharing properties for.
target (matplotlib.axes.Axes, optional) – The target axes to share with. If not provided, the first axes in the array will be used.
sharex (bool, optional) – Whether to share the x-axis between the axes. Defaults to False.
sharey (bool, optional) – Whether to share the y-axis between the axes. Defaults to False.
- show_dendrogram_waveforms(linkage: numpy.array, ax: matplotlib.axes.Axes, depth: int = 30)[source]¶
Generate a dendrogram plot of waveforms and return the leaf node coordinates and population labels.
- Parameters:
linkage (np.array) – The linkage matrix.
ax (matplotlib.axes.Axes) – The axes to plot the dendrogram on.
depth (int, optional) – The depth of the dendrogram. Defaults to 30.