https://github.com/m30m/cluster_pack
A simple tool for visualizing clusters using D3.js
https://github.com/m30m/cluster_pack
cluster-analysis clustering d3-js d3-visualization visual-analytics visualization
Last synced: 3 months ago
JSON representation
A simple tool for visualizing clusters using D3.js
- Host: GitHub
- URL: https://github.com/m30m/cluster_pack
- Owner: m30m
- License: mit
- Created: 2018-05-18T09:36:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T07:58:15.000Z (almost 8 years ago)
- Last Synced: 2025-07-26T16:45:49.168Z (9 months ago)
- Topics: cluster-analysis, clustering, d3-js, d3-visualization, visual-analytics, visualization
- Language: HTML
- Size: 146 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cluster Pack
A tiny python library for visualizing hierarchical clusters using packed circle visualization
# Installation
You can install this package directly from github using the following command:
```sh
pip3 install git+https://github.com/m30m/cluster_pack.git
```
# Usage
## Structure of clustering input
The input should have a structure like the one below:
```python
{
"name": "root",
"children": [
{
"size": 4,
"name": "cluster1"
},
{
"name": "cluster2",
"children": [
{
"size": 3,
"name": "subcluster1"
},
{
"size": 1,
"name": "subcluster2"
}
]
}
]
}
```
Each node can have the following attributes:
```python
{
"name": "root", # name shown on the plot
"children": [...], # array of nodes
"size": 4, # size of the cluster
"color": "red", # can be anything
"info": "any extra information", # this will be shown in the info box next to the plot, it can be arbitrary html
"image": "file://path/to/some/image.jpg" # background of the circle in clustering, useful for image clustering
}
```
Nodes should either have the `children` attribute or `size` attribute if they are leaf nodes.
## API
If you are using jupyter notebook:
```python
from cluster_pack import visualize_notebook
visualize_notebook(clusters, size=900) # size parameter is the width and height of output svg
```
If you want the raw html:
```python
from cluster_pack import visualize
html = visualize(clusters, size=900)
with open('output.html','w') as output_file:
output_file.write(html)
```
# Screenshots
