You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
S += ((np.finfo(np.double).eps * S + np.finfo(np.double).tiny * 100) *
random_state.randn(n_samples, n_samples))
Affinity Propagation uses as_float_array()which allows bothfloat32 and float64 but then hard codes float64 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.
Interesting, thanks for investigating this issue @Wikilicious !
I can reproduce on the master branch with Linux. This is related to the more general #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
The text was updated successfully, but these errors were encountered: