Automatic _*_iterator
s and component_mask
ing for Data Transformers
#1407
Labels
improvement
New feature or improvement
Is your feature request related to a current problem? Please describe.
In order to implement a new data transformer, users currently need to override the
_*_iterator
method (where*
istransform
,fit
, and/orinverse_transform
) if they wish to pass class attributes and/or fitted parameters to their implementedts_transform
/ts_fit
/ts_inverse_transform
methods. Moreover, if users want their transform to be able to 'mask out' particular components using thecomponent_mask
keyword argument, they need to manually call_reshape_in
and_reshape_out
inside of their implementedts_*
method.For a 'solid' example of what I mean, check out the
BoxCox
transformer code - notice how_fit_iterator
,_transform_iterator
, and_inverse_transform_iterator
all need to be overridden to pass fitted parameters to their respective methods. Similarly, each method needs topop
thecomponent_mask
fromkwargs
, and then call_reshape_in
to apply these masks.In my view, these two steps should be made 'automatic' by default (I'll explain precisely what I mean by this shortly), for two reasons:
ts_transform
)_*_iterator
) to achieve something as basic as passing fitted parameters to theirts_transform
method.Describe proposed solution
By default, all fixed parameters (i.e. attributes defined in the child-most class) and fitted parameters (if the transformer is fittable) should be passed to a user's implemented
ts_*
methods. In my view, the easiest way to achieve this is to havets_transform
,ts_fit
, andts_inverse_transform
all accept an additionalparams
argument, whereparams
is adict
that contains up to two keys:fixed
, which is another dictionary that stores the child-most class's attributes (i.e. the fixed parameters of the transformer).fitted
, which stores the fitted parameters returned byts_fit
; if the transformer doesn't inherit fromFittableDataTransformer
orts_fit
has been called, this key shouldn't be present.As a simple illustration of what I mean by this:
Moreover, if
component_mask
is supplied to any of these methods, then theseries
provided to that method will already have the relevant components removed, so the user doesn't need to worry about masking theseries
themselves. Similarly, afterts_transform
/ts_inverse_transform
has returned the transformed components, these should automatically be 'added back' to the original timeseries with the unmasked components. If the user doesn't want this 'automatic masking' behaviour to be applied and, instead, havecomponent_masks
given to them as akwarg
(i.e. current behaviour), there should obviously be an option allowing that.Additional context
I have been working on this change, so I'll post a PR soon.
Any comments and/or suggestions are more than welcome.
Cheers,
Matt.
The text was updated successfully, but these errors were encountered: