Agglomerative Clustering Dendrogram Example "distances_" attribute error
See original GitHub issueDescription
I tried to run the plot dendrogram example as shown in https://scikit-learn.org/dev/auto_examples/cluster/plot_agglomerative_dendrogram.html
Steps/Code to Reproduce
Code is available in the link in the description
Expected Results
Expected results are also documented in the
Actual Results
Traceback (most recent call last):
File "test_agglomerative.py", line 40, in <module>
plot_dendrogram(model, truncate_mode='level', p=3)
File "test_agglomerative.py", line 24, in plot_dendrogram
linkage_matrix = np.column_stack([model.children_, model.distances_,
AttributeError: 'AgglomerativeClustering' object has no attribute 'distances_'
Checking the documentation, it seems that the AgglomerativeClustering object does not have the “distances_” attribute https://scikit-learn.org/dev/modules/generated/sklearn.cluster.AgglomerativeClustering.html#sklearn.cluster.AgglomerativeClustering.
Versions
Version : 0.21.3 Build: pypi_0 Channel: pypi
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
python - AgglomerativeClustering, no attribute called distances_
AgglomerativeClustering () says. distances_ : array-like of shape (n_nodes-1,) Distances between nodes in the corresponding place in ...
Read more >sklearn.cluster.AgglomerativeClustering
Computes distances between clusters even if distance_threshold is not used. This can be used to make dendrogram visualization, but introduces a computational ...
Read more >Hierarchical Clustering | Hierarchical Clustering Python
In hierarchical clustering, we have a concept called a proximity matrix. This stores the distances between each point. Let's take an example ......
Read more >Definitive Guide to Hierarchical Clustering with Python and ...
What are the different linking methods and distance metrics applied to dendrograms and clustering algorithms; What are the agglomerative and ...
Read more >Hierarchical Clustering in R: Dendrograms with hclust
For example if you have continuous numerical values in your dataset you can use euclidean distance, if the data is binary you may...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please upgrade scikit-learn to version 0.22
Me either. scikit-learn-0.22.1
I was able to get it to work using a distance matrix:
Error:
Works: