image_output_1.png
from glob import glob

import matplotlib.pylab as plt

import pandas as pd

train_img = glob('../input/kaggle-pog-series-s01e03/corn/train/*.png')
test_img = glob('../input/kaggle-pog-series-s01e03/corn/test/*.png')
train_df = pd.read_csv('../input/kaggle-pog-series-s01e03/corn/train.csv')
test_df = pd.read_csv('../input/kaggle-pog-series-s01e03/corn/test.csv')

def get_index(view,label):
    return train_df[(train_df.view==view) & (train_df.label==label)].index[0]
def plots(label):
    # top
    img_mpl1 = plt.imread(train_img[get_index('top',label)])
    ax = pd.Series(img_mpl1.flatten()).rename(f'top {label.capitalize()}').plot(kind='hist',bins=50,legend=True)
    ax.set_title(f'{label.capitalize()} Corn',pad=40)
    ax.title.set_size(28)
    fig = ax.get_figure()
    fig.tight_layout()
    # bottom broken 
    img_mpl2 = plt.imread(train_img[get_index('bottom',label)])
    pd.Series(img_mpl2.flatten()).rename(f'bottom {label.capitalize()}').plot(kind='hist',bins=50,legend=True)
    
    # pictures 
    fig, axs= plt.subplots(1,2,figsize=(8,8))
    axs[0].imshow(img_mpl1)
    axs[1].imshow(img_mpl2)
    axs[0].set_title('Top')
    axs[0].title.set_size(20)
    axs[1].set_title('Bottom')
    axs[1].title.set_size(20)
    plt.show()

ax = train_df.groupby(['label'])['image'].count().plot(kind='pie', figsize=(10, 10), title='Corn Type Ratio', autopct='%1.1f%%', shadow=True, fontsize=15)
ax.title.set_size(25)