Пример #1
0
def test_minmax_scaler_clip(setup, feature_range):
    # test behaviour of the parameter 'clip' in MinMaxScaler
    X = iris
    scaler = MinMaxScaler(feature_range=feature_range, clip=True).fit(X)
    X_min, X_max = mt.min(X, axis=0), mt.max(X, axis=0)
    X_test = [mt.r_[X_min[:2] - 10, X_max[2:] + 10]]
    X_transformed = scaler.transform(X_test)
    assert_allclose(X_transformed, [[
        feature_range[0], feature_range[0], feature_range[1], feature_range[1]
    ]])
Пример #2
0
 def testMinmaxScalerClip(self):
     for feature_range in [(0, 1), (-10, 10)]:
         # test behaviour of the paramter 'clip' in MinMaxScaler
         X = self.iris
         scaler = MinMaxScaler(feature_range=feature_range,
                               clip=True).fit(X)
         X_min, X_max = mt.min(X, axis=0), mt.max(X, axis=0)
         X_test = [mt.r_[X_min[:2] - 10, X_max[2:] + 10]]
         X_transformed = scaler.transform(X_test)
         assert_allclose(X_transformed, [[
             feature_range[0], feature_range[0], feature_range[1],
             feature_range[1]
         ]])
Пример #3
0
def test_minmax_scale_axis1(setup):
    X = iris
    X_trans = minmax_scale(X, axis=1)
    assert_array_almost_equal(mt.min(X_trans, axis=1), 0)
    assert_array_almost_equal(mt.max(X_trans, axis=1), 1)
Пример #4
0
 def testMinmaxScaleAxis1(self):
     X = self.iris
     X_trans = minmax_scale(X, axis=1)
     assert_array_almost_equal(mt.min(X_trans, axis=1), 0)
     assert_array_almost_equal(mt.max(X_trans, axis=1), 1)