Kaggle competition: Digit Recognizer
<SOS> metric: categorizationaccuracy Kaggle data source: digit-recognizer<groupby>
mnist_test = pd.read_csv(".. /input/mnist-in-csv/mnist_test.csv")
 mnist_train = pd.read_csv(".. /input/mnist-in-csv/mnist_train.csv" )
subm = cell_df.groupby(['image_id'])['pred'].apply(lambda x: ' '.join(x)).reset_index()
subm.head()<load_from_csv>
sample_submission = pd.read_csv(".. /input/digit-recognizer/sample_submission.csv")
 test = pd.read_csv(".. /input/digit-recognizer/test.csv")
 train = pd.read_csv(".. /input/digit-recognizer/train.csv" )
sample_submission = pd.read_csv('.. /input/hpa-single-cell-image-classification/sample_submission.csv')
 sample_submission.head()<merge>
test['dataset'] = 'test'
sub = pd.merge(
 sample_submission,
subm,
how="left",
left_on='ID',
right_on='image_id', 
)
 sub.head()<feature_engineering>
train['dataset'] = 'train'
def isNaN(num):
return num != num
for i, row in sub.iterrows() :
if isNaN(row['pred']): continue
sub.PredictionString.loc[i] = row['pred']<save_to_csv>
dataset = pd.concat([train.drop('label', axis=1), test] ).reset_index()
sub.to_csv('submission.csv', index=False )<save_to_csv>
mnist = pd.concat([mnist_train, mnist_test] ).reset_index(drop=True)
 labels = mnist['label'].values
mnist.drop('label', axis=1, inplace=True)
 mnist.columns = cols
sub.to_csv('submission.csv', index=False )<load_from_csv>
idx_mnist = mnist.sort_values(by=list(mnist.columns)).index
dataset_from = dataset.sort_values(by=list(mnist.columns)) ['dataset'].values
original_idx = dataset.sort_values(by=list(mnist.columns)) ['index'].values
data_train = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')
 data_test = pd.read_csv('/kaggle/input/digit-recognizer/test.csv' )<count_missing_values>
for i in range(len(idx_mnist)) :
if dataset_from[i] == 'test':
sample_submission.loc[original_idx[i], 'Label'] = labels[idx_mnist[i]]
<create_dataframe><EOS> 
sample_submission.to_csv('submission.csv', index=False )