# Path: deepcpg/utils.py
# def get_from_module(identifier, module_params, ignore_case=True):
#     """Return object from module.
# 
#     Return object with name `identifier` from module with items `module_params`.
# 
#     Parameters
#     ----------
#     identifier: str
#         Name of object, e.g. a function, in module.
#     module_params: dict
#         `dict` of items in module, e.g. `globals()`
#     ignore_case: bool
#         If `True`, ignore case of `identifier`.
# 
#     Returns
#     -------
#     object
#         Object with name `identifier` in module, e.g. a function or class.
#     """
#     if ignore_case:
#         _module_params = dict()
#         for key, value in six.iteritems(module_params):
#             _module_params[key.lower()] = value
#         _identifier = identifier.lower()
#     else:
#         _module_params = module_params
#         _identifier = identifier
#     item = _module_params.get(_identifier)
#     if not item:
#         raise ValueError('Invalid identifier "%s"!' % identifier)
#     return item


from collections import OrderedDict
from scipy.stats import kendalltau
from six.moves import range
from .data import CPG_NAN, OUTPUT_SEP
from .utils import get_from_module
import numpy as np
import pandas as pd
import sklearn.metrics as skm
    report = pd.pivot_table(report, index=index, columns='metric',
                            values='value')
    report.reset_index(index, inplace=True)
    report.columns.name = None

    # Sort columns
    columns = list(report.columns)
    sorted_columns = []
    for fun in CAT_METRICS + CLA_METRICS + REG_METRICS:
        for i, column in enumerate(columns):
            if column.startswith(fun.__name__):
                sorted_columns.append(column)
    sorted_columns = index + sorted_columns
    sorted_columns += [col for col in columns if col not in sorted_columns]
    report = report[sorted_columns]
    order = []
    if 'auc' in report.columns:
        order.append(('auc', False))
    elif 'mse' in report.columns:
        order.append(('mse', True))
    elif 'acc' in report.columns:
        order.append(('acc', False))
    report.sort_values([x[0] for x in order],
                       ascending=[x[1] for x in order],
                       inplace=True)
    return report


def get(name):
    """Return object from module by its name."""

# Path: deepcpg/utils.py
# def get_from_module(identifier, module_params, ignore_case=True):
#     """Return object from module.
# 
#     Return object with name `identifier` from module with items `module_params`.
# 
#     Parameters
#     ----------
#     identifier: str
#         Name of object, e.g. a function, in module.
#     module_params: dict
#         `dict` of items in module, e.g. `globals()`
#     ignore_case: bool
#         If `True`, ignore case of `identifier`.
# 
#     Returns
#     -------
#     object
#         Object with name `identifier` in module, e.g. a function or class.
#     """
#     if ignore_case:
#         _module_params = dict()
#         for key, value in six.iteritems(module_params):
#             _module_params[key.lower()] = value
#         _identifier = identifier.lower()
#     else:
#         _module_params = module_params
#         _identifier = identifier
#     item = _module_params.get(_identifier)
#     if not item:
#         raise ValueError('Invalid identifier "%s"!' % identifier)
#     return item


# Path: deepcpg/evaluation.py
from collections import OrderedDict
from scipy.stats import kendalltau
from six.moves import range
from .data import CPG_NAN, OUTPUT_SEP
from .utils import get_from_module
import numpy as np
import pandas as pd
import sklearn.metrics as skm

    report = pd.pivot_table(report, index=index, columns='metric',
                            values='value')
    report.reset_index(index, inplace=True)
    report.columns.name = None

    # Sort columns
    columns = list(report.columns)
    sorted_columns = []
    for fun in CAT_METRICS + CLA_METRICS + REG_METRICS:
        for i, column in enumerate(columns):
            if column.startswith(fun.__name__):
                sorted_columns.append(column)
    sorted_columns = index + sorted_columns
    sorted_columns += [col for col in columns if col not in sorted_columns]
    report = report[sorted_columns]
    order = []
    if 'auc' in report.columns:
        order.append(('auc', False))
    elif 'mse' in report.columns:
        order.append(('mse', True))
    elif 'acc' in report.columns:
        order.append(('acc', False))
    report.sort_values([x[0] for x in order],
                       ascending=[x[1] for x in order],
                       inplace=True)
    return report


def get(name):
    """Return object from module by its name."""

    return get_from_module(name, globals())