text_plain_output_1.png
from sklearn.preprocessing import MultiLabelBinarizer

import numpy as np

import pandas as pd

train_df = pd.read_csv('../input/imet-2020-fgvc7/train.csv')
train_df['attribute_ids'] = train_df['attribute_ids'].apply(lambda x: x.split(' '))
train_df['id'] = train_df['id'].apply(lambda x: x + '.png')

from sklearn.preprocessing import MultiLabelBinarizer
mlb = MultiLabelBinarizer()
train_df_d = pd.DataFrame(mlb.fit_transform(train_df['attribute_ids']), columns=mlb.classes_, index=train_df.index)

label_names = train_df_d.columns

sam_sub_df = pd.read_csv('../input/imet-2020-fgvc7/sample_submission.csv')
sam_sub_df['id'] = sam_sub_df['id'].apply(lambda x: x + '.png')

probs.shape

threshold = probs[0].mean()
labels_01 = (probs > threshold).astype(np.int)
labels_01

labels_01.shape

sub = pd.DataFrame(labels_01, columns=label_names)

sub.head()