Closed Wikilicious closed 4 years ago
Interesting, thanks for investigating this issue @Wikilicious !
I can reproduce on the master branch with Linux. This is related to the more general https://github.com/scikit-learn/scikit-learn/issues/5776 issue. A PR to fix it (with some unit tests) would be welcome.
Description
Degeneracies not removed from a
float32
matrix because it's hard coded to use float64. This causes incorrect clusters for special cases.Here is the root cause of the issue:
Affinity Propagation uses
as_float_array()
which allows bothfloat32
andfloat64
but then hard codesfloat64
through out the rest.The ideal solution is to declare the dtype of the input matrix and use that through out the code. Additionally, the other variables (A, R, tmp, e) should be declared using the same dtype as the user input.
Steps/Code to Reproduce
Here is a very simple example where you can intuitively see there should be 3 clusters.
Expected Results
If k is
float64
, it gives the correct results.Actual Results
Versions
Windows-10-10.0.16299-SP0 Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] NumPy 1.14.0 SciPy 1.0.0 Scikit-Learn 0.19.1