Ejemplo n.º 1
0
Jaime Sendra Berenguer-2020.
MLearner Machine Learning Library Extensions
Author:Jaime Sendra Berenguer<www.linkedin.com/in/jaisenbe>
License: MIT
"""

import numpy as np
import pytest
from mlearner.data import data_uniform, data_normal, data_gamma, create_dataset

n = 1000
config = {
    'A': data_uniform(0, 1, n),
    'B': data_normal(n),
    'C': data_normal(mu=5, sd=2, n=n),
    'D': data_gamma(a=5, n=n)
}
config_bad = np.array([1, 2, 3])


def test_config_bad():
    with pytest.raises(TypeError):
        create_dataset(config_bad, n)


def test_type_n():
    with pytest.raises(TypeError):
        create_dataset(config, float(n))


def test_minor_n():
Ejemplo n.º 2
0
def test_float_n_minor():
    with pytest.raises(NameError):
        data_gamma(a, 0)
Ejemplo n.º 3
0
def test_result_mean():
    data = data_gamma(a, n)
    assert (np.mean(data) > np.median(data))
Ejemplo n.º 4
0
def test_float_n():
    with pytest.raises(TypeError):
        data_gamma(a, float(n))
Ejemplo n.º 5
0
def test_type_n():
    with pytest.raises(TypeError):
        data_gamma(a, str(n))
Ejemplo n.º 6
0
def test_type_a():
    with pytest.raises(TypeError):
        data_gamma(str(a), n)
Ejemplo n.º 7
0
def test_data_len():
    data = data_gamma(a, n)
    assert (len(data) == n)
Ejemplo n.º 8
0
"""Jaime Sendra Berenguer-2020.
MLearner Machine Learning Library Extensions
Author: Jaime Sendra Berenguer<www.linkedin.com/in/jaisenbe>
License: MIT
"""

import numpy as np
import pytest
from mlearner.preprocessing import FixSkewness
from mlearner.data import data_gamma, create_dataset

n = 5
config = {
    'A': data_gamma(a=2.5, n=n),
    'B': data_gamma(a=3.5, n=n),
    'C': data_gamma(a=4, n=n),
    'D': data_gamma(a=5, n=n),
    'E': np.repeat("KO", n)
}
data = create_dataset(config, n)
data_error = [1, 2, 3, 4, 1, 2, 3, 4]
col = ["D"]
col_error = np.array([1, 2])
col_object = ["E"]


def test_error_type_col():
    with pytest.raises(TypeError):
        FixSkewness(columns=col_error)