Esempio n. 1
0
def test_row_transformer_sklearn_transfomer():
    mu = 10
    X = _make_nested_from_array(
        np.random.normal(loc=mu, scale=5, size=(100,)), n_instances=10, n_columns=1
    )
    t = StandardScaler(with_mean=True, with_std=True)
    r = SeriesToSeriesRowTransformer(t, check_transformer=False)

    Xt = r.fit_transform(X)
    assert Xt.shape == X.shape
    assert isinstance(
        Xt.iloc[0, 0], (pd.Series, np.ndarray)
    )  # check series-to-series transform
    np.testing.assert_almost_equal(Xt.iloc[0, 0].mean(), 0)  # check standardisation
    np.testing.assert_almost_equal(Xt.iloc[0, 0].std(), 1, decimal=2)
Esempio n. 2
0
def test_row_transformer_function_transformer_series_to_series():
    X, y = load_gunpoint(return_X_y=True)

    # series-to-series transform function
    def powerspectrum(x):
        fft = np.fft.fft(x)
        ps = fft.real * fft.real + fft.imag * fft.imag
        return ps[: ps.shape[0] // 2]

    ft = FunctionTransformer(func=powerspectrum, validate=False)
    t = SeriesToSeriesRowTransformer(ft, check_transformer=False)
    Xt = t.fit_transform(X, y)
    assert Xt.shape == X.shape
    assert isinstance(
        Xt.iloc[0, 0], (pd.Series, np.ndarray)
    )  # check series-to-series transforms
Esempio n. 3
0
EXCLUDED_TESTS = {
    "ShapeletTransformClassifier": ["check_fit_idempotent"],
    "ContractedShapeletTransform": ["check_fit_idempotent"],
}

# We here configure estimators for basic unit testing, including setting of
# required hyper-parameters and setting of hyper-parameters for faster training.
SERIES_TO_SERIES_TRANSFORMER = StandardScaler()
SERIES_TO_PRIMITIVES_TRANSFORMER = FunctionTransformer(np.mean,
                                                       kw_args={"axis": 0},
                                                       check_inverse=False)
TRANSFORMERS = [
    (
        "transformer1",
        SeriesToSeriesRowTransformer(SERIES_TO_SERIES_TRANSFORMER,
                                     check_transformer=False),
    ),
    (
        "transformer2",
        SeriesToSeriesRowTransformer(SERIES_TO_SERIES_TRANSFORMER,
                                     check_transformer=False),
    ),
]
REGRESSOR = LinearRegression()
TIME_SERIES_CLASSIFIER = TimeSeriesForest(n_estimators=3)
TIME_SERIES_CLASSIFIERS = [
    ("tsf1", TIME_SERIES_CLASSIFIER),
    ("tsf2", TIME_SERIES_CLASSIFIER),
]
FORECASTER = ExponentialSmoothing()
FORECASTERS = [("ses1", FORECASTER), ("ses2", FORECASTER)]