# AssertionError in K-medoids algorithm

**URL:** https://discourse.julialang.org/t/assertionerror-in-k-medoids-algorithm/116425
**Category:** General Usage
**Tags:** package, jump, cluster, clustering
**Created:** [June 30, 2024, 12:12pm UTC](https://discourse.julialang.org/t/assertionerror-in-k-medoids-algorithm/116425 "2024-06-30T12:12:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Hasselvej](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@Hasselvej](https://discourse.julialang.org/u/Hasselvej)
#### Post date: [June 30, 2024, 12:12pm UTC](https://discourse.julialang.org/t/assertionerror-in-k-medoids-algorithm/116425/1 "2024-06-30T12:12:20Z")

</div>

I am using K-medoids to reduce my data (potential future scenarios of a stock’s price) from 400 scenarios to n = 25. I computed the distance matrix based on the Eucledian distance:

```julia
C = pairwise(Euclidean(), data', data')

```

where `data` are my 400 scenarios - the data file can be found at [link](https://github.com/JuliaStats/Clustering.jl/issues/281). Then I run K-medoids:

```julia
kmedoids(C, n, init = :kmpp)

```

I get the error:

```julia
ERROR: AssertionError: !(isempty(grp))

```

Does any of you know what could be wrong? It seems to run fine in Python (from sklearn\_extra.cluster import KMedoids), but I guess the two K-medoids functions are different. I haven’t been able to find any documentation on why it fails…
