Use a similarity vector with the dimension of all possible similarities, which initially are set to zero everywhere. Go over the shared images of one user and for each image set the vector to 1 at the positions of the similarities from the image.
Do the same for another user.
Use the scalar product as similarity metric between the two users.
You can add ...
If you want to group your dataset into k different group based on some feature( here checkout history) you can use K Means Clustering algorithm to cluster them into different groups.
You will find sklearn k means clustering module helpful. All you need to do is provide the data into it and choose appropriate hyperparameters.