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)What the rule reports
Section titled “What the rule reports”TimeSeriesImputer("constant") or TimeSeriesImputer(method="constant") calls that omit value=.
How to fix it
Section titled “How to fix it”Pass a finite fill value such as value=0.0, or switch method to "mean", "median", "ffill", "bfill", or "linear".
Diagnostic message
Section titled “Diagnostic message”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.