import numpy as np
from pyts.preprocessing import StandardScaler, MinMaxScaler, MaxAbsScaler, RobustScaler
from pyts.preprocessing import KBinsDiscretizer, InterpolationImputer
def generate():
fixtures = []
rng = np.random.RandomState(42)
X = rng.randn(4, 8)
scaler = StandardScaler()
result = scaler.transform(X)
fixtures.append({
"test_name": "standard_scaler_basic",
"params": {"with_mean": True, "with_std": True},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
scaler = StandardScaler(with_mean=False)
result = scaler.transform(X)
fixtures.append({
"test_name": "standard_scaler_no_mean",
"params": {"with_mean": False, "with_std": True},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
scaler = MinMaxScaler()
result = scaler.transform(X)
fixtures.append({
"test_name": "minmax_scaler_basic",
"params": {"sample_range": [0, 1]},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
scaler = MaxAbsScaler()
result = scaler.transform(X)
fixtures.append({
"test_name": "maxabs_scaler_basic",
"params": {},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
scaler = RobustScaler()
result = scaler.transform(X)
fixtures.append({
"test_name": "robust_scaler_basic",
"params": {"quantile_range": [25, 75]},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
disc = KBinsDiscretizer(n_bins=4, strategy="uniform")
result = disc.transform(X)
fixtures.append({
"test_name": "discretizer_uniform",
"params": {"n_bins": 4, "strategy": "uniform"},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
disc = KBinsDiscretizer(n_bins=3, strategy="quantile")
result = disc.transform(X)
fixtures.append({
"test_name": "discretizer_quantile",
"params": {"n_bins": 3, "strategy": "quantile"},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
disc = KBinsDiscretizer(n_bins=4, strategy="normal")
result = disc.transform(X)
fixtures.append({
"test_name": "discretizer_normal",
"params": {"n_bins": 4, "strategy": "normal"},
"input": {"X": X.tolist()},
"expected": {"output": result.tolist()},
"tolerance": 1e-10,
})
return fixtures