Preprocessing simpleimputeroptions - CyrilB1531/lodestar GitHub Wiki
Development build. This page describes
main, not a released package. The latest published Lodestar.Preprocessing is 0.1.0 — read its documentation.
Home › Preprocessing › Encoding and imputation
SimpleImputerOptions
How SimpleImputer fills a missing value, and what to do with an empty feature.
public sealed record SimpleImputerOptions
Properties — Strategy chooses the statistic, FillValue is what
ImputationStrategy.Constant fills with (zero by default), and
KeepEmptyFeatures decides what happens to a feature with no value at all —
sklearn.impute.SimpleImputer's strategy, fill_value and keep_empty_features.
Example — a constant the caller chose, and a feature that has nothing to average.
using Lodestar.Preprocessing;
double[] samples = [1.0, double.NaN, 3.0];
SimpleImputer constant = SimpleImputer.Fit(
samples,
1,
new SimpleImputerOptions { Strategy = ImputationStrategy.Constant, FillValue = -1.0 });
string filled = string.Join(",", constant.Transform(samples)); // => 1,-1,3
Remarks — KeepEmptyFeatures is where this package and the reference differ. Its default
drops an empty feature from the output; here that is refused, and this option fills the feature
instead — the reference's keep_empty_features=True. It fills with zero, except under Constant,
which fills with FillValue as the reference does. Either way the output has as many columns as
the input, which the reference's default does not guarantee.
Applies to — net10.0, netstandard2.0.
See also — SimpleImputer.Fit, ImputationStrategy.