# Path: xcessiv/functions.py
# def hash_file(path, block_size=65536):
# def hash_string(string):
# def import_object_from_path(path, object):
# def import_object_from_string_code(code, object):
# def import_string_code_as_module(code):
# def verify_dataset(X, y):
# def is_valid_json(x):
# def make_serializable(json):
# def get_sample_dataset(dataset_properties):
# def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties):
# def get_path_from_query_string(req):
#     def __init__(self, path):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# class DBContextManager():
# 
# Path: xcessiv/presets/metricsetting.py



import unittest
import numpy as np
from sklearn.datasets import load_iris, load_breast_cancer, load_boston
from sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.model_selection import cross_val_predict
from xcessiv import functions
from xcessiv.presets import metricsetting

regression_X, regression_y = load_boston(return_X_y=True)
reg = LinearRegression()
regression_preds = cross_val_predict(reg, regression_X, regression_y, method='predict')


class TestAccuracyFromScores(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.accuracy_from_scores['source'])

        assert np.round(module.metric_generator(binary_y, binary_probas), 2) == 0.95
        assert np.round(module.metric_generator(multiclass_y, multiclass_probas), 2) == 0.95

        del module


class TestAccuracyFromPreds(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.accuracy_from_preds['source'])

        assert np.round(module.metric_generator(binary_y, binary_preds), 2) == 0.95
        assert np.round(module.metric_generator(multiclass_y, multiclass_preds), 2) == 0.95

        del module


class TestRecallFromScores(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.recall_from_scores['source'])


# Path: xcessiv/functions.py
# def hash_file(path, block_size=65536):
# def hash_string(string):
# def import_object_from_path(path, object):
# def import_object_from_string_code(code, object):
# def import_string_code_as_module(code):
# def verify_dataset(X, y):
# def is_valid_json(x):
# def make_serializable(json):
# def get_sample_dataset(dataset_properties):
# def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties):
# def get_path_from_query_string(req):
#     def __init__(self, path):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# class DBContextManager():
# 
# Path: xcessiv/presets/metricsetting.py



# Path: xcessiv/presets/tests/test_metricsetting.py
import unittest
import numpy as np
from sklearn.datasets import load_iris, load_breast_cancer, load_boston
from sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.model_selection import cross_val_predict
from xcessiv import functions
from xcessiv.presets import metricsetting


regression_X, regression_y = load_boston(return_X_y=True)
reg = LinearRegression()
regression_preds = cross_val_predict(reg, regression_X, regression_y, method='predict')


class TestAccuracyFromScores(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.accuracy_from_scores['source'])

        assert np.round(module.metric_generator(binary_y, binary_probas), 2) == 0.95
        assert np.round(module.metric_generator(multiclass_y, multiclass_probas), 2) == 0.95

        del module


class TestAccuracyFromPreds(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.accuracy_from_preds['source'])

        assert np.round(module.metric_generator(binary_y, binary_preds), 2) == 0.95
        assert np.round(module.metric_generator(multiclass_y, multiclass_preds), 2) == 0.95

        del module


class TestRecallFromScores(unittest.TestCase):
    def test_source(self):
        module = functions.import_string_code_as_module(metricsetting.recall_from_scores['source'])


        assert np.round(module.metric_generator(binary_y, binary_probas), 2) == 0.97