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

df = pd.read_csv('/kaggle/input/tmnist-typeface-mnist/TMNIST_data.csv')

unique_typefaces = df.names.unique()
typeface_map = {}
for i in range(len(unique_typefaces)):
    typeface_map[unique_typefaces[i]] = i
df = df.replace({'names': typeface_map})

df = df.sample(frac=1).reset_index(drop=True)
training_percent = 0.7
validation_percent = 0.2
total_examples = df.shape[0]
train_val_breakpoint = int(training_percent * total_examples)
val_test_breakpoint = int((training_percent + validation_percent) * total_examples)
train_df = df.iloc[None:train_val_breakpoint, :]
val_df = df.iloc[train_val_breakpoint:val_test_breakpoint, :]
test_df = df.iloc[val_test_breakpoint:None, :]
for z in zip(['train_df', 'val_df', 'test_df'], [train_df, val_df, test_df]):
    print(f'Shape of {z[0]}:', z[1].shape)