return model


ensemble_model = ensemble(models)
# error = evaluate_error(ensemble_model)
# print(error)
"""Predict"""
pred1 = ensemble_model.predict_generator(test_gen,
                                         steps=len(test_gen),
                                         verbose=1)
"""Generate file for submission in kaggle"""
test_df = test.join(
    pd.DataFrame(pred1,
                 columns=[
                     'any', 'epidural', 'intraparenchymal', 'intraventricular',
                     'subarachnoid', 'subdural'
                 ]))

# Unpivot table
test_df = test_df.melt(id_vars=['filename'])

# Combine the filename column with the variable column
test_df['ID'] = test_df.filename.apply(
    lambda x: x.replace('.png', '')) + '_' + test_df.variable
test_df['Label'] = test_df['value']

print("[INFO]Creating submission.csv...")
test_df[['ID', 'Label']].to_csv('submission.csv', index=False)
test_df[['ID', 'Label']].head(10)
print("[INFO]Download completed!")