Spectral Clustering Using Deep Neural Networks
Project description
SpectralNet
SpectralNet is a python package that performs spectral clustering with deep neural networks.
This package is based on the following paper - SpectralNet
Installation
You can install the latest package version via
pip install spectralnet
Usage
The basic functionlaity is quite intuitive and easy to use, e.g.,
from spectralnet import SpectralNet
spectralnet = SpectralNet(n_clusters=10)
spectralnet.fit(X) # X is the dataset and it should be a torch.Tensor
cluster_assignments = spectralnet.predict(X) # Get the final assignments to clusters
If you have labels to your dataset and you want to measure ACC and NMI you can do the following:
from spectralnet import SpectralNet
from spectralnet import Metrics
spectralnet = SpectralNet(n_clusters=2)
spectralnet.fit(X, y) # X is the dataset and it should be a torch.Tensor
cluster_assignments = spectralnet.predict(X) # Get the final assignments to clusters
y = y_train.detach().cpu().numpy() # In case your labels are of torch.Tensor type.
acc_score = Metrics.acc_score(cluster_assignments, y, n_clusters=2)
nmi_score = Metrics.nmi_score(cluster_assignments, y)
print(f"ACC: {np.round(acc_score, 3)}")
print(f"NMI: {np.round(nmi_score, 3)}")
You can read the code docs for more information and functionalities
Citation
@inproceedings{shaham2018,
author = {Uri Shaham and Kelly Stanton and Henri Li and Boaz Nadler and Ronen Basri and Yuval Kluger},
title = {SpectralNet: Spectral Clustering Using Deep Neural Networks},
booktitle = {Proc. ICLR 2018},
year = {2018}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spectralnet-0.0.3.tar.gz
(15.5 kB
view hashes)
Built Distribution
Close
Hashes for spectralnet-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54e29da386594dd17b444ee22a673f9202ab19387d501322c4f83ee6ac11e297 |
|
MD5 | 4c17873a7bf54d4c48513aadc86fef3f |
|
BLAKE2b-256 | 9de124c2021fed0f369f3b9a7e40c5e3d29d133ca7949c8d48d79e2c62fb3bbe |