spclustering


Namespclustering JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/ferchaure/SPC/
SummaryPython Wrapper for Superparamagnetic Clustering
upload_time2023-01-07 21:53:26
maintainer
docs_urlNone
authorFernando Julian Chaure
requires_python
license
keywords clustering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # spclustering: Super Paramagnetic Clustering Wrapper

This is a Python Ctypes wrapper for the original SPC algorithm (available in [Eytan Domany repository](https://github.com/eytandomany/SPC)). The SPC code was edited to work as a shared library, reduce disk usage and improve speed and interface with Python.

## How to install spclustering

```bash
pip install spclustering
```

## How to build spclustering

The original code requires gcc and makefile. For Windows I recommend [TDM-GCC](https://jmeubank.github.io/tdm-gcc/).


## How to use spclustering

```python
from spclustering import SPC
import matplotlib.pyplot as plt
import numpy as np

rng = np.random.RandomState(0)

cl1 = rng.multivariate_normal([8, 8], [[4,0],[0,3]], size=400)
cl2 = rng.multivariate_normal([0,0], [[3,0],[0,2]], size=1000)
data = np.concatenate([cl1,cl2])

clustering = SPC(mintemp=0.02,maxtemp=0.04)
results = clustering.run(data)

#select a temperature (similar to select a distance in a dendogram)
temp = 1

plt.plot(*data[results[temp,:]==0,:].T,'.r')
plt.plot(*data[results[temp,:]==1,:].T,'.b')
plt.plot(*data[results[temp,:]>1,:].T,'.k')

plot.show()

```

## Limitations and Changes

- It runs with a data matrix [npoints, ndims] as input. Running the clustering from a distance matrix is not implemented.

- Only the main parameters and flags are implemented.

- Tmax (stop temperature) is not included in the temperature array (similar to Python ```range```). 

- Included *WriteEdges* boolean parameter (defaul False). If True, the \*.edges/\*.mst/\*.K file is created as in the original SPC. Added aswell *PrintParam* parameter in the legacy SW.c code.

- Reduces/removes console ouputs.

## Original SPC Citation

Blatt, M., Wiseman, S., & Domany, E. (1996). Superparamagnetic clustering of data. Physical review letters, 76(18), 3251.

```bibtex
@article{spc,
  title={Superparamagnetic clustering of data},
  author={Blatt, Marcelo and Wiseman, Shai and Domany, Eytan},
  journal={Physical review letters},
  volume={76},
  number={18},
  pages={3251},
  year={1996},
  publisher={APS}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ferchaure/SPC/",
    "name": "spclustering",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "clustering",
    "author": "Fernando Julian Chaure",
    "author_email": "fchaure@fi.uba.ar",
    "download_url": "",
    "platform": null,
    "description": "# spclustering: Super Paramagnetic Clustering Wrapper\n\nThis is a Python Ctypes wrapper for the original SPC algorithm (available in [Eytan Domany repository](https://github.com/eytandomany/SPC)). The SPC code was edited to work as a shared library, reduce disk usage and improve speed and interface with Python.\n\n## How to install spclustering\n\n```bash\npip install spclustering\n```\n\n## How to build spclustering\n\nThe original code requires gcc and makefile. For Windows I recommend [TDM-GCC](https://jmeubank.github.io/tdm-gcc/).\n\n\n## How to use spclustering\n\n```python\nfrom spclustering import SPC\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nrng = np.random.RandomState(0)\n\ncl1 = rng.multivariate_normal([8, 8], [[4,0],[0,3]], size=400)\ncl2 = rng.multivariate_normal([0,0], [[3,0],[0,2]], size=1000)\ndata = np.concatenate([cl1,cl2])\n\nclustering = SPC(mintemp=0.02,maxtemp=0.04)\nresults = clustering.run(data)\n\n#select a temperature (similar to select a distance in a dendogram)\ntemp = 1\n\nplt.plot(*data[results[temp,:]==0,:].T,'.r')\nplt.plot(*data[results[temp,:]==1,:].T,'.b')\nplt.plot(*data[results[temp,:]>1,:].T,'.k')\n\nplot.show()\n\n```\n\n## Limitations and Changes\n\n- It runs with a data matrix [npoints, ndims] as input. Running the clustering from a distance matrix is not implemented.\n\n- Only the main parameters and flags are implemented.\n\n- Tmax (stop temperature) is not included in the temperature array (similar to Python ```range```). \n\n- Included *WriteEdges* boolean parameter (defaul False). If True, the \\*.edges/\\*.mst/\\*.K file is created as in the original SPC. Added aswell *PrintParam* parameter in the legacy SW.c code.\n\n- Reduces/removes console ouputs.\n\n## Original SPC Citation\n\nBlatt, M., Wiseman, S., & Domany, E. (1996). Superparamagnetic clustering of data. Physical review letters, 76(18), 3251.\n\n```bibtex\n@article{spc,\n  title={Superparamagnetic clustering of data},\n  author={Blatt, Marcelo and Wiseman, Shai and Domany, Eytan},\n  journal={Physical review letters},\n  volume={76},\n  number={18},\n  pages={3251},\n  year={1996},\n  publisher={APS}\n}\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python Wrapper for Superparamagnetic Clustering",
    "version": "0.0.3",
    "split_keywords": [
        "clustering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "011486a421eb4d34b6c88d7a63589680d9d9afe6962704f62d2afb116e66a677",
                "md5": "1aedcd928c03bccb3381f6544fbfa829",
                "sha256": "b947b7e2b18cd20203af948a52b63360ee2d7b1cf7b4251a70c118a2e40cc674"
            },
            "downloads": -1,
            "filename": "spclustering-0.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "1aedcd928c03bccb3381f6544fbfa829",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 63755,
            "upload_time": "2023-01-07T21:53:26",
            "upload_time_iso_8601": "2023-01-07T21:53:26.655597Z",
            "url": "https://files.pythonhosted.org/packages/01/14/86a421eb4d34b6c88d7a63589680d9d9afe6962704f62d2afb116e66a677/spclustering-0.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-07 21:53:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ferchaure",
    "github_project": "SPC",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "spclustering"
}
        
Elapsed time: 0.07918s