Neven Armanios May, 2024
KMeans was used to cluster a set of images based on their metadata. The success of the clustering was determined subjectively; the right features and number of clusters were decided upon by visually inspecting whether images in each cluster appeared to belong together. The optimal number of clusters, chosen based on the combined results of the highest average silhouette score and the presence or lack of a silhouette bar for every cluster. Despite 25 clusters having the actual highest score, this range displayed silhouettes with empty clusters (i.e no data). Therefore 22 clusters proved to perform the best. See Silhouettes for more information.
https://github.com/narmanios/Machine-Learning-Clustering
The images represent over 400 works of fine art from museum collections and galleries across several countries.
The provided code snippet outlines how the KMeans clustering was implemented to organize a set of images based on selected metadata features. The variables used include, X = data['primary_medium', 'representation', 'representation_semi', 'spatial_dimension']. Here is a detailed breakdown of each component of the code:
The elbow graph was visualized within a range of 1-101 at first and the observation was made that an optimal range would be somewhere in the range of 20-25. Therefore the inertia was visualized again using a range of 1-26.
Many different cluster ranges were run including; range_n_clusters = [4, 5, 10, 15, 20, 21, 22, 23, 24, 25]. The lower values (values below 20) were used (despite the results of the inertia visualization) just to confirm that the cluster ranges in the 20s was stronger. Below are images of the silhouette results for the lowest range (4) that was explored and the two highest ranges (22 and 25).
Cluster n=25 gave a stronger accuracy result that n=22. However, 22 was determined to be the stronger cluster range, because each silhouette contained data. In cluster n=25 clusters appeared empty of data.
cluster range = 4
cluster range = 22
cluster range = 25