My last post “Using Keras’ Pre-trained Models for Feature Extraction in Image Clustering” described a study about using deep-learning image-recognition models for feature extraction in clustering a set of dog/cat images. One interesting question is how can we visualize the results in two dimensional space. Here is how it looks like.
Some notes on designing and implementing our solution.
- Keras’ pre-trained model ResNet50 is used for feature extraction, and Scikit-Learn’s clustering algorithm kMeans is used for feature clustering. [ref]
- Figure 1 illustrates cosine similarity between the feature of an image and the center of cluster 1 or the center of cluster 2, where cosine similarity is implemented by using SciPy. [ref]
- In Figure 1, whether a point is in red or is in blue depends on the label predicted by kMeans in Scikit-Learn, not on the ground truth.
- Figure 2 and Figure 3 are interactive diagrams showing a dog image or a cat image upon the mouse hovering over a point. The effect is implemented by using Offsetbox in Matplotlib. [ref]
Here are some pictures around the boundary of two clusters.
Alright … love the data … 😄
Here are some pictures around the edge of a cluster.
Hate the pets in cage … 😡
Any comments from data scientists or pet lovers?