Transformer
TransformIf
Conditional execution of a transformer given a condition from a fittable object.
Quickstart
python
from sktime.transformations.compose import TransformIf
estimator = TransformIf(if_estimator, param=None, condition='bool', condition_value=None, then_trafo=None, else_trafo=None)Parameters(6)
- if_estimatorsktime estimator, must have fit
sktime estimator to fit and apply to series. this is a “blueprint” estimator, state does not change when
fitis called- paramstr, optional, default = first boolean parameter of fitted if_estimator
- conditionstr, optional, default = “bool”
condition that defines whether self behaves like
then_estorelse_estthis estimator behaves likethen_estiff: “bool” = ifparamis True “>”, “>=”, “==”, “<”, “<=”, “!=” = ifparam condition condition_value- condition_valuerequired for some conditions, see above; otherwise optional
- then_trafosktime transformer, optional, default=``if_estimator``
transformer that this behaves as if condition is satisfied this is a “blueprint” transformer, state does not change when
fitis called- else_trafosktime transformer, optional default=``Id`` (identity/no transform)
transformer that this behaves as if condition is not satisfied this is a “blueprint” transformer, state does not change when
fitis called
Examples
>>> from sktime.param_est.seasonality import SeasonalityACF
>>> from sktime.transformations.compose import TransformIf
>>> from sktime.transformations.detrend import Deseasonalizer
>>> from sktime.datasets import load_airline
>>>
>>> y = load_airline ()
>>>
>>> seasonal = SeasonalityACF (candidate_sp = 12)
>>> deseason = Deseasonalizer (sp = 12)
>>> cond_deseason = TransformIf (seasonal, "sp", "!=", 1, deseason)
>>> y_hat = cond_deseason. fit_transform (y)