image_output_1.png
from collections import Counter

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

import tensorflow as tf

import tensorflow as tf
import numpy as np
video_lvl_record = '../input/video_level/train-1.tfrecord'
frame_lvl_record = '../input/frame_level/train-1.tfrecord'
vid_ids = []
labels = []
mean_rgb = []
mean_audio = []
for example in tf.python_io.tf_record_iterator(video_lvl_record):
    tf_example = tf.train.Example.FromString(example)
    vid_ids.append(tf_example.features.feature['video_id'].bytes_list.value[0].decode(encoding='UTF-8'))
    labels.append(tf_example.features.feature['labels'].int64_list.value)
    mean_rgb.append(tf_example.features.feature['mean_rgb'].float_list.value)
    mean_audio.append(tf_example.features.feature['mean_audio'].float_list.value)

n = 20
from collections import Counter
label_mapping = pd.Series.from_csv('../input/label_names.csv', header=0)
label_dict = label_mapping.to_dict()
top_n = Counter([item for sublist in labels for item in sublist]).most_common(n)
top_n_labels = [int(i[0]) for i in top_n]
top_n_label_count = [int(i[1]) for i in top_n]
top_n_label_names = [label_dict[x] for x in top_n_labels]
top_labels = pd.DataFrame(data=top_n_labels, columns=['label_num'])
top_labels['count'] = top_n_label_count
top_labels['label_name'] = top_n_label_names
top_labels = top_labels.drop('label_num', axis=1)
import seaborn as sns
import matplotlib.pyplot as plt
ax = sns.barplot(x='label_name', y='count', data=top_labels)
ax.set(xlabel='Label Name', ylabel='Label Count')
ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=45)
_ = plt.show()