Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/letiantian/kmedoids
[Unmaintained] The Python implementation of k-medoids.
https://github.com/letiantian/kmedoids
Last synced: about 2 months ago
JSON representation
[Unmaintained] The Python implementation of k-medoids.
- Host: GitHub
- URL: https://github.com/letiantian/kmedoids
- Owner: letiantian
- Archived: true
- Created: 2016-03-08T08:17:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-08T02:15:52.000Z (about 4 years ago)
- Last Synced: 2024-05-19T23:35:39.033Z (4 months ago)
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 125
- Watchers: 6
- Forks: 86
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kmedoids
The Python implementation of [k-medoids](https://en.wikipedia.org/wiki/K-medoids).## Example
```python
from sklearn.metrics.pairwise import pairwise_distances
import numpy as npimport kmedoids
# 3 points in dataset
data = np.array([[1,1],
[2,2],
[10,10]])# distance matrix
D = pairwise_distances(data, metric='euclidean')# split into 2 clusters
M, C = kmedoids.kMedoids(D, 2)print('medoids:')
for point_idx in M:
print( data[point_idx] )print('')
print('clustering result:')
for label in C:
for point_idx in C[label]:
print('label {0}: {1}'.format(label, data[point_idx]))
```Output:
```
medoids:
[1 1]
[10 10]clustering result:
label 0: [1 1]
label 0: [2 2]
label 1: [10 10]
```## License
This code is from:> Bauckhage C. Numpy/scipy Recipes for Data Science: k-Medoids Clustering[R]. Technical Report, University of Bonn, 2015.
Please cite the article if the code is used in your research.