Comments (6)
Hi, thanks for taking the time and filing a issue. Can you please provide the full error as I think you have forgot to include it? Could you also provide me with the sklearn, scipy and numpy version. And what system are you using? Mac/Linux/Windows?
from k-means-constrained.
Thanks for the quick response, and sorry for the omission. The exception is getting thrown by this check on line 483 of k_means_contrained_.py:
if min_cost_flow.Solve() != min_cost_flow.OPTIMAL:
raise Exception('There was an issue with the min cost flow input.')
Digging into it deeper, I see that min_cost_flow.Solve() is returning 3, while min_cost_flow.OPTIMAL is 1.
Versions:
numpy==1.13.3
scikit_learn==0.24.1
k-means-constrained==0.5.1
OS: Ubuntu 18.04.5
from k-means-constrained.
Could you also please provide a minimal working example that produces the error
from k-means-constrained.
from k_means_constrained import KMeansConstrained
import numpy as np
X = np.array([[11.43817265911908, 3.0796017788793604], [8.656592391707292, -0.5358447753622294], [7.302104968579831, -2.2195335805441103], [7.1817782508003924, 5.142237391259907], [6.672130682774286, 1.9154397778535366], [6.335350488151739, -5.14734393191299], [-4.467719064297461, 2.198353204833053], [6.259064200368242, 4.7330446470564445], [10.769348531911556, 0.7475931768575942], [12.555003395037621, -0.8724602182508533], [10.9665526970981, -4.4246780352423]])
clf = KMeansConstrained(n_clusters=2, size_min=2, size_max=5, random_state=0)
clf.fit_predict(X)
Traceback (most recent call last):
File "/home/tatooine/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 5, in
clf.fit_predict(X)
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained_.py", line 730, in fit_predict
return self.fit(X).labels_
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained_.py", line 642, in fit
return_n_iter=True)
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained_.py", line 180, in k_means_constrained
x_squared_norms=x_squared_norms, random_state=random_state)
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained_.py", line 328, in kmeans_constrained_single
labels_constrained(X, centers, size_min, size_max, distances=distances)
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained.py", line 399, in labels_constrained
labels = solve_min_cost_flow_graph(edges, costs, capacities, supplies, n_C, n_X)
File "/home/tatooine/.local/lib/python3.6/site-packages/k_means_constrained/k_means_constrained.py", line 484, in solve_min_cost_flow_graph
raise Exception('There was an issue with the min cost flow input.')
Exception: There was an issue with the min cost flow input.
from k-means-constrained.
Hi @zjorgensenbits,
The constraints you have provided make the problem unsolvable i.e. you have 11 data points and said you want 2 clusters with max size 5. There is no way of solving this as 2*5=10<11
.
However, the user input should be validated before trying to solve the solve_min_cost_flow_graph - I will add to the code 😃 thanks.
Josh
from k-means-constrained.
doh! you're right--I'm an idiot. I misinterpreted "min_size" and "max_size" as the min and max number of clusters...
I'll go ahead and close this. Thanks for catching my error!
from k-means-constrained.
Related Issues (20)
- facing the issue during running HOT 2
- [BUG] Failed to build k-means-constrained HOT 3
- Wrong clustering HOT 1
- Wrong clustering with pre_computed adjacency matrix HOT 3
- QGIS implementation HOT 1
- ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject HOT 2
- [How to classify the new instances after obtaining a constrained clustering] HOT 1
- [BUG] error compiling on apple silicon. HOT 2
- Maybe tag a new release? HOT 1
- Issue in importing k-means-constrained in Google Colab notebook HOT 2
- Possibility to use this on k-modes HOT 2
- Can't install k-means-constrained HOT 2
- Resource intensity HOT 2
- Weighting observations HOT 1
- import k_means_constrained HOT 4
- Issue with min cost flow input HOT 2
- Segmentation fault when import k_means_constrained
- Is it possible to implement MiniBatchKmeansConstrained?
- [BUG] IndexError: index 10000 is out of bounds for axis 0 with size 10000
- conda version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k-means-constrained.