Skip to content

tslearn/imputer-constant-missing-value

Pack Severity Fix Versions
tslearn warning none, edit by hand All versions

TimeSeriesImputer.__init__ sets value: Optional[float] = math.nan. When method="constant" is selected without an explicit value, numpy.where(numpy.isnan(ts), self.value, ts) replaces every NaN with NaN, leaving missing entries un-imputed.

imp = TimeSeriesImputer(method="constant")
imp = TimeSeriesImputer(method="constant", value=0.0)

TimeSeriesImputer("constant") or TimeSeriesImputer(method="constant") calls that omit value=.

Pass a finite fill value such as value=0.0, or switch method to "mean", "median", "ffill", "bfill", or "linear".

TimeSeriesImputer(method="constant") defaults value=math.nan, leaving every NaN unchanged. Pass an explicit constant fill value such as value=0.0.

See all rules in the tslearn pack.