# OUTPUT PREDICTION
{% if pipeline.task.is_multiclass == True and pipeline.adaptation_metric == "LogLoss"%}
prediction = pd.DataFrame(columns={{ pipeline.task.id_columns_for_prediction }}, data=__test_dataset_prediction_columns, index=__test_dataset_prediction_columns.index)
prediction = pd.concat([prediction, pd.DataFrame(__y_pred, columns=__model.classes_, index=__test_dataset_prediction_columns.index)], axis=1)
prediction.to_csv("./prediction_result.csv", index=False)

{% elif pipeline.adaptation_metric.startswith("MAP_") %}
{% set k = pipeline.adaptation_metric.split("_")[1] %}
prediction = pd.DataFrame(columns={{ pipeline.task.id_columns_for_prediction }}, data=__test_dataset_prediction_columns, index=__test_dataset_prediction_columns.index)
prediction = pd.concat([prediction, pd.DataFrame(__y_pred, columns=[_TARGET_COLUMNS[0] + "_" +str(i) for i in range(1, __y_pred.shape[1] + 1)], index=__test_dataset_prediction_columns.index)], axis=1)
prediction.to_csv("./prediction_result.csv", index=False)

{% elif pipeline.task.is_multiclass == True and (pipeline.adaptation_metric in ["auc", "ROC_AUC", "Gini"]) %}
prediction = pd.DataFrame(columns={{ pipeline.task.id_columns_for_prediction }}, data=__test_dataset_prediction_columns, index=__test_dataset_prediction_columns.index)
prediction = pd.concat([prediction, pd.DataFrame(__model.classes_[np.argmax(__y_pred, axis=1)], columns=_TARGET_COLUMNS, index=__test_dataset_prediction_columns.index)], axis=1)
prediction.to_csv("./prediction_result.csv", index=False)
{% else %}
prediction = pd.DataFrame(columns={{ pipeline.task.id_columns_for_prediction }}, data=__test_dataset_prediction_columns, index=__test_dataset_prediction_columns.index)
prediction = pd.concat([prediction, pd.DataFrame(__y_pred, columns=_TARGET_COLUMNS, index=__test_dataset_prediction_columns.index)], axis=1)
prediction.to_csv("./prediction_result.csv", index=False)

{% endif %}