Metadata-Version: 2.1
Name: idendrogram
Version: 0.2.0
Summary: Interactive dendrograms compatible with scipy, scikit-learn and hdbscan
Keywords: dendrogram,hierarchical clustering,clustering
Author: Aurimas Racas
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Dist: scipy >= 1.8.0
Requires-Dist: numpy >= 1.22.0
Requires-Dist: matplotlib ; extra == "full"
Requires-Dist: altair>=1.4.2 ; extra == "full"
Requires-Dist: plotly ; extra == "full"
Requires-Dist: hdbscan ; extra == "full"
Requires-Dist: scikit-learn ; extra == "full"
Requires-Dist: pandas ; extra == "full"
Requires-Dist: streamlit ; extra == "streamlit"
Project-URL: Documentation, https://github.com/kamicollo/idendrogram
Project-URL: Home, https://github.com/kamicollo/idendrogram
Provides-Extra: full
Provides-Extra: streamlit

# idendrogram

idendrogram helps you create nicer, interactive visualizations of hierarchical clustering trees (a.k.a. dendrograms) from clustering outputs generated by your preferred hierarchical clustering library (SciPy, Scikit-learn or HDBSCAN) in your preferred python visualization library (Altair, Plotly or Matplotlib)

It also supports bi-directional Streamlit integration via a custom D3-powered component.

<img src='docs/gallery/custom-radii.png' width=500>
<img src='docs/gallery/streamlit-integration.gif' width=500>

## Installation

To use the main package:

```pip install idendrogram```

To use the bi-directional Streamlit component:

```pip install idendrogram idendrogram-streamlit-component``` 

## Basic usage 

```python
import idendrogram
import scipy.cluster.hierarchy as sch
from idendrogram.targets.altair import to_altair

#cluster the data
linkage_matrix = sch.linkage(
    data['data'], method='single', metric='euclidean'
)
threshold = 0.8
flat_clusters = sch.fcluster(
    linkage_matrix, t=threshold, criterion='distance'
)

#wrap clustering outputs / parameters into a container
cl_data = idendrogram.ClusteringData(
    linkage_matrix = linkage_matrix, 
    cluster_assignments = flat_clusters
)

#pass to idendrogram and visualize
idd = idendrogram.idendrogram()
idd.set_cluster_info(cl_data)
dendrogram = idd.create_dendrogram(truncate_mode='level', p=10)
to_altair(dendrogram=dendrogram, height=200, width=629)
```

For more, see docs at https://kamicollo.github.io/idendrogram/

