In [21]:
import pandas as pd
import numpy as np
from collections import Counter
from matplotlib import pyplot as plt
import os
import cv2
%matplotlib inline
In [22]:
%%javascript
IPython.OutputArea.auto_scroll_threshold = 9999;
In [23]:
def load_filepaths():
    imdir_ideology = 'ideology_image_dataset/'
    ideology_files=os.listdir('ideology_image_dataset/')
    ideology_files_path=[os.path.join(imdir_ideology,file) for file in ideology_files ]
    
    return ideology_files_path
In [24]:
ideology_files_path=load_filepaths()
len(ideology_files_path)
Out[24]:
2942
In [25]:
def showClustering(predicted_labels,label):
    label_indexs= np.where(predicted_labels==label)[0]
    print("CLUSTER--> ",label,"TOTAL IMAGES--> ",len(label_indexs))
    if(len(label_indexs)>=500):
        fig=plt.figure(figsize=(10, 400))
        
        
    elif(len(label_indexs)>100 and len(label_indexs)<500):
        fig=plt.figure(figsize=(10, 70))
    elif(len(label_indexs)>=50 and len(label_indexs)<100):
        fig=plt.figure(figsize=(10, 30))
        
    elif(len(label_indexs)>=20 and len(label_indexs)<50):
        fig=plt.figure(figsize=(10, 20))
    
    elif(len(label_indexs)>=0 and len(label_indexs)<20):
        fig=plt.figure(figsize=(10, 8))
    
    for i,index in enumerate(label_indexs):
       
        
        image = cv2.imread(ideology_files_path[index])
        image= cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        
        columns = 4
        rows = np.ceil(len(label_indexs)/float(columns))
        
        fig.add_subplot(rows,columns, i+1)
        plt.imshow(image)
    
   
    plt.show()
All the clusters are very less , so not visualizing the results

VGG16

In [26]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_vgg_16.npy-umap.csv')
results_df
Out[26]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 4 0.455908 2898.159708 0.797047
1 Agglomerative clustering 3 0.466930 3245.870427 0.815268

VGG19

In [27]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_vgg_19.npy-umap.csv')
results_df
Out[27]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.596841 5667.314615 0.533134
1 Agglomerative clustering 3 0.598175 3049.559688 0.408998

Resnet 50

In [28]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_resnet50.npy-umap.csv')
results_df
Out[28]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.469655 2992.991273 0.805054
1 Agglomerative clustering 2 0.536244 146.237947 0.336664

Inceptionv3

In [29]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_inceptionv3.npy-umap.csv')
results_df
Out[29]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.550547 5368.965384 0.650664
1 Agglomerative clustering 2 0.535155 5017.265224 0.680570

Inception-resnetv2

In [30]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_inception-resentv2.npy-umap.csv')
results_df
Out[30]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.548607 5685.308006 0.641595
1 Agglomerative clustering 2 0.501131 4243.828944 0.644213

Densenet121

In [31]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_densenet121.npy-umap.csv')
results_df
Out[31]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 3 0.502810 3453.622430 0.677723
1 Agglomerative clustering 3 0.503308 3411.602651 0.677478

Densenet169

In [32]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_densenet169.npy-umap.csv')
results_df
Out[32]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.632416 7662.046458 0.495615
1 Agglomerative clustering 2 0.632905 7625.771036 0.490600

Densenet201

In [33]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_densenet201.npy-umap.csv')
results_df
Out[33]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 3 0.582275 6922.426124 0.562016
1 Agglomerative clustering 3 0.576271 6709.639577 0.562743

Xception

In [34]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_xception.npy-umap.csv')
results_df
Out[34]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.554196 4806.851053 0.615450
1 Agglomerative clustering 4 0.519510 2340.364878 0.460864

Mobilenet

In [35]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_model_mobilenet.npy-umap.csv')
results_df
Out[35]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 3 0.648912 680.498971 0.245534
1 Agglomerative clustering 4 0.653376 594.270938 0.227947

Grayscale

In [36]:
results_df=pd.read_csv('D://Himani-work/gsoc2020/code/image-results-hier/ideology_gray_scale.npy-umap.csv')
results_df
Out[36]:
Unnamed: 0 n_clusters silhouette calinski davies
0 Birch 2 0.597864 2080.035684 0.618577
1 Agglomerative clustering 2 0.601689 1989.810501 0.587518
In [ ]:
 
In [ ]: