darts icon indicating copy to clipboard operation
darts copied to clipboard

Enable feature reduction using data transformers

Open NBeugen opened this issue 10 months ago • 1 comments

When defining a Pipeline using sklearn scalers such as: pipeline = Pipeline([Scaler(scaler = StandardScaler()), Scaler(scaler = PCA(n_components = 0.1, svd_solver = 'full'))]) And transforming a Sequence of Timeseries using: test = pipeline.fit_transform(covars)

The resulting error is given as output: The new values must have the same shape (time, components) as the present series.

I figure that the Transformer class is not able to perform feature reduction, or have less components as the new values than the present series.

Describe proposed solution It would be great to have the option of dimensionality reduction for transforming Timeseries or a Sequence of Timeseries.

Describe potential alternatives Not aware of any alternatives in the Darts package. My solution currently is processing everything using dataframes in sklearn.

NBeugen avatar Apr 19 '24 10:04 NBeugen

Hi @NBeugen,

The Scaler derived objects are intended to modify the range of the values only, not the shape of the TimeSeries.

If you want to modify the number of components, by inserting new one or removing some, you need to define a new class FeaturesProjection, inheriting from the BaseDataTransformer (doc) that implement the feature selection/transformation logic in the ts_transform method .

madtoinou avatar Apr 25 '24 07:04 madtoinou