I have looked everywhere and I can't find a straight solution. I have a set of metadata from images and their elements (name, heigh, width, position{top, right}). I would like to create categories of images based on relative positions of several items in the image.


img1 has 

logo in top x1, right y1, and is height h1 and width w1

text in top x2, right y2, and is height h2 and width w2

from img1 to n

I thought about running a KNN classifier to find images that are more similar to others but I am having trouble thinking about how to organize the data.

Should I group them by image? In which case: how would KNN or other algorithms work on grouped data? Should I do OHE to know if there is a specific element? Would it be better to use a DecisionTree?

Its my first data science job, and there is nobody with seniority here so I am having trouble organizing this dataset.

Thanks in advance!

  • $\begingroup$ (In python or R) I know this might be a little too much or specific to ask, but I do want to make this job work. $\endgroup$ Commented Jun 4, 2019 at 14:42

1 Answer 1


You could try to apply a dimension reduction technique to map all of the variables into 2, such as t-SNE or UMAP (I recommend this one), and then apply a clustering algorithm based on densities, such as HDBSCAN.

Be mind that each run of the HDBSCAN might return different results. Scale all the variables before starting to apply the algorithms (scale)

Links to these algorithms in R: UMAP: HDBSCAN


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.