コード例 #1
0
def test_transform_4x1_1(data):
    bc = BoxCox()
    trans = bc.fit_transform(data[0])
    assert np.all(trans == data[2])
    assert trans.shape == data[2].shape
    inverse = bc.inverse_transform(trans)
    assert np.allclose(inverse, data[0])
    assert inverse.shape == data[0].shape
コード例 #2
0
def test_transform_4x4_1(data):
    bc = BoxCox()
    bc.fit_transform(data[1])
    trans = bc.transform(data[1][:2])
    assert trans.shape == data[3][:2].shape
    assert np.all(trans == data[3][:2])
    inverse = bc.inverse_transform(trans)
    assert inverse.shape == data[1][:2].shape
    assert np.allclose(inverse, data[1][:2])
コード例 #3
0
def test_transform_4x1_ravel_2(data):
    bc = BoxCox()
    bc.fit(data[0].ravel())
    trans = bc.transform((data[0].ravel())[:2])
    assert trans.shape == (data[2].ravel())[:2].shape
    assert np.all(trans == (data[2].ravel())[:2])
    inverse = bc.inverse_transform(trans)
    assert inverse.shape == (data[0].ravel())[:2].shape
    assert np.allclose(inverse, (data[0].ravel())[:2])
コード例 #4
0
def test_transform_4x1_2(data):
    from scipy.special import boxcox as bc_
    shift = 1e-5
    bc = BoxCox(shift=shift)
    _data = data[0] - 2.
    trans = bc.fit_transform(_data)
    tmp = bc_(_data + (shift - _data.min()), bc.lambda_[0])
    assert np.all(trans == tmp)
    inverse = bc.inverse_transform(trans)
    assert np.allclose(inverse, _data)
コード例 #5
0
def test_transform_4x1_ravel_1(data):
    bc = BoxCox()
    trans = bc.fit_transform(data[0].ravel())
    assert np.all(trans == data[2].ravel())
    inverse = bc.inverse_transform(trans)
    assert np.allclose(inverse, data[0].ravel())
コード例 #6
0
def test_transform_err_4x4_3(data):
    bc = BoxCox(on_err='log')
    trans = bc.fit_transform(data[5])
    assert np.all(trans == data[7])
    inverse = bc.inverse_transform(trans)
    assert np.all(inverse == data[5])
コード例 #7
0
def test_transform_err_4x4(data):
    bc = BoxCox()
    trans = bc.fit_transform(data[5])
    assert np.all(trans == data[5])
    inverse = bc.inverse_transform(trans)
    assert np.all(inverse == data[5])
コード例 #8
0
def test_transform_4x4_2(data):
    bc = BoxCox()
    trans = bc.fit_transform(data[1])
    assert np.all(trans == data[3])
    inverse = bc.inverse_transform(trans)
    assert np.allclose(inverse, data[1])