sklearn.cluster.DBSCAN gives unexpected result
<p>I'm using DBSCAN method for clustering images, but it gives unexpected result. Let's assume I have 10 images. </p>

<p>Firstly, I read an images in a loop using <code>cv2.imread</code>.
Then I compute structural similarity index between each images. After that, I have a matrix like this:</p>

<pre><code>[
[ 1.         -0.00893619  0.          0.          0.          0.50148778      0.47921832  0.          0.          0.        ]

[-0.00893619  1.          0.          0.          0.          0.00996088     -0.01873205  0.          0.          0.        ]

[ 0.          0.          1.          0.57884212  0.          0.             0.         0.          0.          0.        ]

[ 0.          0.          0.57884212  1.          0.          0.              0.         0.          0.          0.        ]

[ 0.  0.  0.  0.  1.  0.  0.  0.  0.  0.]

[ 0.50148778  0.00996088  0.          0.          0.          1.          0.63224396  0.          0.          0.        ]

[ 0.47921832 -0.01873205  0.          0.          0.          0.63224396      1.          0.          0.          0.        ]

[ 0.          0.          0.          0.          0.          0.          0.  1.          0.77507487  0.69697053]

[ 0.          0.          0.          0.          0.          0.          0.  0.77507487  1.          0.74861881]

[ 0.          0.          0.          0.          0.          0.          0.  0.69697053  0.74861881  1.        ]]
</code></pre>

<p>Looks good. Then I have simple invokation of DBSCAN:</p>

<pre><code>db = DBSCAN(eps=0.4, min_samples=3, metric='precomputed').fit(distances)
labels = db.labels_
n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)
</code></pre>

<p>And the result is</p>

<pre><code>[0 0 0 0 0 0 0 0 0 0]
</code></pre>

<p>What do I do wrong? Why it puts all images into one cluster?</p>

<p>DBSCAN usually assumes a <em>dissimilarity</em> (distance) not a similarity. It can be implemented with a similarity threshold, too (see Generalized DBSCAN)</p>

python scikit-learn cluster-analysis dbscan