# Path: veidt/utils/general_utils.py
# def deserialize_veidt_object(identifier, module_objects=None,
#                              printable_module_name='object'):
#     if isinstance(identifier, dict):
#         # dealing with configuration dictionary
#         config = identifier
#         if 'class_name' not in config or 'config' not in config:
#             raise ValueError('Improper config format: ' + str(config))
#         class_name = config['class_name']
#         module_objects = module_objects or {}
#         cls = module_objects.get(class_name)
#         if cls is None:
#             raise ValueError('Unknown ' + printable_module_name +
#                              ': ' + class_name)
#         return cls(**config['config'])
# 
#     elif isinstance(identifier, str):
#         function_name = identifier
#         fn = module_objects.get(function_name)
#         if fn is None:
#             raise ValueError('Unknown ' + printable_module_name +
#                              ':' + function_name)
#         return fn
# 
# Path: veidt/utils/general_utils.py
# def serialize_veidt_object(instance):
#     if instance is None:
#         return None
#     if hasattr(instance, 'get_config'):
#         return {
#             'class_name': instance.__class__.__name__,
#             'config': instance.get_config()
#         }
#     if hasattr(instance, '__name__'):
#         return instance.__name__
#     else:
#         raise ValueError('Cannot serialize', instance)


import numpy as np
from sklearn.metrics import mean_squared_error, mean_absolute_error
from veidt.utils.general_utils import deserialize_veidt_object
from veidt.utils.general_utils import serialize_veidt_object



def binary_accuracy(y_true, y_pred):
    return np.mean(np.array(y_true).ravel() == np.array(y_pred).ravel())


mse = MSE = mean_squared_error
mae = MAE = mean_absolute_error


def serialize(metric):

# Path: veidt/utils/general_utils.py
# def deserialize_veidt_object(identifier, module_objects=None,
#                              printable_module_name='object'):
#     if isinstance(identifier, dict):
#         # dealing with configuration dictionary
#         config = identifier
#         if 'class_name' not in config or 'config' not in config:
#             raise ValueError('Improper config format: ' + str(config))
#         class_name = config['class_name']
#         module_objects = module_objects or {}
#         cls = module_objects.get(class_name)
#         if cls is None:
#             raise ValueError('Unknown ' + printable_module_name +
#                              ': ' + class_name)
#         return cls(**config['config'])
# 
#     elif isinstance(identifier, str):
#         function_name = identifier
#         fn = module_objects.get(function_name)
#         if fn is None:
#             raise ValueError('Unknown ' + printable_module_name +
#                              ':' + function_name)
#         return fn
# 
# Path: veidt/utils/general_utils.py
# def serialize_veidt_object(instance):
#     if instance is None:
#         return None
#     if hasattr(instance, 'get_config'):
#         return {
#             'class_name': instance.__class__.__name__,
#             'config': instance.get_config()
#         }
#     if hasattr(instance, '__name__'):
#         return instance.__name__
#     else:
#         raise ValueError('Cannot serialize', instance)


# Path: veidt/metrics.py
import numpy as np
from sklearn.metrics import mean_squared_error, mean_absolute_error
from veidt.utils.general_utils import deserialize_veidt_object
from veidt.utils.general_utils import serialize_veidt_object




def binary_accuracy(y_true, y_pred):
    return np.mean(np.array(y_true).ravel() == np.array(y_pred).ravel())


mse = MSE = mean_squared_error
mae = MAE = mean_absolute_error


def serialize(metric):

    return serialize_veidt_object(metric)