I use Nearest Neighbour function of Scikit learn module in python for training and compare an image set (https://docs.google.com/file/d/0B6zJ3_hrkW40U182SWNWX3o4dE0/edit?usp=sharing&pli=1) By deafult NN function use euclidean distance, but in these way it mixes all feature without giving a weight.

I use feature like solidity, and Humoment that are rotation and scale invariant.

my features:
[[solidity,1sthumoment,2ndhumoment, 3rdhumoment, 4thhumoment, 5thhumoment,6thhumoment,7thhumoment][...]...]

[[0.87044372948387361, 0.063642083932879651, 0.12356758667941924, 0.0079915727336300653, 0.0002061055245765021, 0.0019832214511596759, 0.000143483068555641, 0.17750220723974636]
[0.43762295557263098, 0.032602517700434798, 0.0045084338591890975, 0.00040343031030726695, -4.3220757761746937e-07, 4.1662265592274961e-05, -3.3048990436934407e-07, 2.83559235524301e-05]
[0.67217292360607472, 0.21411359416298198, 0.038240138048085716, 0.00056521478226677867, 1.6126276972407056e-06, 0.00020982069131408694, -2.0746983237760103e-06, 0.00030014256771966684]
[0.51893243284454049, 0.14486098229876093, 0.007011404157031503, 0.00042653374379056195, -6.0947207554547829e-07, 0.00015935932421697882, -4.1548384524149294e-07, 0.0013995801259622112]
[0.72398269966588791, 0.31689878513436764, 0.00089365579831210602, 0.00022784188716352421, 6.83376830706894e-08, -5.1956738361704706e-05, 7.6810569991291178e-08, 0.0005244526025960404]

Which are the best similarity metrics i could use for that image set, with that features ?

Here (http://scikit-learn.org/dev/modules/generated/sklearn.neighbors.KNeighborsClassifier.html) i saw Minkowski metric,manhattan_distance, euclidean_distance

"Parameter for the Minkowski metric from sklearn.metrics.pairwise.pairwise_distances. When p = 1, this is equivalent to using manhattan_distance (l1), and euclidean_distance (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used"

or maybe:" a user-defined function which accepts an array of distances, and returns an array of the same shape containing the weights."

  • $\begingroup$ It's very difficult to read you post. I realize you probably don't have enough reputation to insert images, etc. Is there a way I can help you edit it for the sake of better formatting and readability? $\endgroup$
    – Phonon
    Feb 13, 2013 at 8:32
  • $\begingroup$ Hard to say with only 4 rows, but these columns don't look normalized. I don't know if scikit does that for you, otherwise it could explain bad performance. Try dividing each column by its standard deviation. $\endgroup$ Feb 13, 2013 at 8:59
  • $\begingroup$ Also normalized i think i couldn't give priority to feature than another, or not? What you need, all the value features? here there are image samples: docs.google.com/file/d/0ByS6Z5WRz-h2NDgySmJ6NnpId0U/edit, docs.google.com/file/d/0ByS6Z5WRz-h2WHEzNnJucDlRR2s/edit $\endgroup$
    – postgres
    Feb 13, 2013 at 9:42

1 Answer 1


You can use the Structural Similarity Index (SSIM).
It's not a distance per se, but you can use it in this case.

  • $\begingroup$ Might be dangerous if it doesn't satisfy the triangle inequality. $\endgroup$ Dec 4, 2023 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.