from functools import partial

import numpy as np
import sklearn

from utils.evaluation import *


def get_eval_functions(model_configuration: dict):
    """
    Returns the evaluation functions for the model
    :return: list of evaluation functions
    """
    eval_functions = [
        {
            "name": "mean_absolute_error_overall",
            "input_index": 0,
            "eval_fn": sklearn.metrics.mean_absolute_error,
            "accumulation_fn": np.mean,
        },
        {
            "name": "mean_absolute_error_pre_ov",
            "input_index": 0,
            "eval_fn": pre_ov_error,
            "accumulation_fn": np.mean,
        },
        {
            "name": "mean_absolute_error_after_ov",
            "input_index": 0,
            "eval_fn": after_ov_error,
            "accumulation_fn": np.mean,
        },
        {
            "name": "mean_absolute_error_ov_in_days",
            "input_index": 0,
            "eval_fn": partial(ov_error, model_configuration=model_configuration),
            "accumulation_fn": np.mean,
        },
        {
            "name": "mean_absolute_error_five_days_before_ov",
            "input_index": 0,
            "eval_fn": partial(day_relative_to_ov_error,
                               day_relative_to_ov=-5,
                               model_configuration=model_configuration),
            "accumulation_fn": np.mean,
        }
    ]
    return eval_functions
