Simple imputation¶
Marginal imputation replaces every missing entry by a statistic of its own column — the mean, the median, or a fixed constant — computed over the samples for which the view is observed. It ignores the correlations between views, which makes it the natural baseline: a strategy that cannot beat it is not exploiting the multi-view structure at all.
Marginal, per-view imputation of missing views.
- class polyview.imputation.simple.SimpleViewImputer(*args: Any, **kwargs: Any)¶
Bases:
BaseViewImputerFill missing views with a per-view, per-feature constant.
Each column of each view gets one statistic, computed over the samples for which that view is observed; every
NaNin the column is then replaced by it. This is the multi-view counterpart ofsklearn.impute.SimpleImputerand the natural baseline any other strategy should be compared against: it ignores the correlations between views, so a missing view contributes nothing beyond its own mean.- Parameters:
strategy ({"mean", "median", "constant"}, default="mean") – Statistic used as fill value.
"constant"usesfill_value.fill_value (float, default=0.0) – Value used when
strategy="constant".n_views (int or None, default=None) – Expected number of views.
Noneaccepts any count.
- statistics_¶
Fill value of each column of each view, shape
(n_features_i,).- Type:
list of ndarray
- missing_view_mask_¶
Truewhere a whole view was missing at fit time.- Type:
ndarray of bool of shape (n_samples, n_views)
- missing_rate_¶
Fraction of fit samples for which each view was missing.
- Type:
ndarray of shape (n_views,)
Notes
A column that is
NaNfor every fit sample has no statistic to learn; it is filled with 0.0 rather than raising, so that a view which is missing for the whole training set does not break a pipeline.Examples
>>> import numpy as np >>> from polyview.imputation import SimpleViewImputer >>> X1 = np.array([[1.0, 2.0], [3.0, 4.0], [np.nan, np.nan]]) >>> X2 = np.array([[5.0], [6.0], [7.0]]) >>> filled = SimpleViewImputer().fit_transform([X1, X2]) >>> filled[0] array([[1., 2.], [3., 4.], [2., 3.]])