SimpleImputer
Fill missing values using a simple univariate per-column strategy.
Each feature is imputed independently using one of four strategies:
"mean": replace missing values with the column mean (numeric only)."median": replace with the column median (numeric only)."most_frequent": replace with the most common value (works with strings and numeric data)."constant": replace with a fixedfill_valuesupplied by the user.
Columns with all-missing values are handled according to the
keep_empty_features flag. When add_indicator=True, a
MissingIndicator binary matrix is stacked onto the output.
Output typing preserves the original column type whenever the strategy
does not force a fractional result: "most_frequent" and
"constant" never perform arithmetic, so the source type (Integer,
Float, or Categorical) is kept. For "mean"/"median" the computed
per-column statistic is inspected, and an originally-Integer column
stays Integer if that statistic happens to be a whole number (e.g. a
median over an odd count of integers); otherwise it becomes Float64.
Wraps sklearn.impute.SimpleImputer.
References
Parameters
- strategy : string, default=
mean - The imputation strategy.
- fill_value, default=
None - The value to replace missing values with.
- add_indicator : boolean, default=
False - If True, a MissingIndicator transform will stack onto output.
- keep_empty_features : boolean, default=
False - If True, empty features will be kept.
Methods
fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'SimpleImputer'
SimpleImputerFit the imputer, remembering input types and column order.
Parameters
- x : DashAIDataset
- The input dataset to fit the imputer on.
- y : DashAIDataset, optional
- Ignored; present for API consistency.
Returns
- SimpleImputer
- The fitted imputer instance (self).
get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType
SimpleImputerReturn the DashAI data type produced by this converter for a column.
Parameters
- column_name : str, optional
- The name of the output column. Defaults to None.
Returns
- DashAIDataType
Integerfor the binaryMissingIndicatorcolumns appended whenadd_indicator=True. Otherwise, the original column type for"most_frequent"/"constant"(no arithmetic is performed on the values), or for"mean"/"median",Integerif the source column was an Integer and the computed statistic is a whole number — otherwise a Float type backed bypyarrow.float64().
get_metadata(cls) -> 'Dict[str, Any]'
BaseConverterGet metadata for the converter, used by the DashAI frontend.
Parameters
- cls : type
- The converter class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'
SklearnWrapperTransform the data using the fitted scikit-learn transformer.
Parameters
- x : DashAIDataset
- The input dataset to transform.
- y : DashAIDataset, optional
- Not used. Present for API consistency. Defaults to None.
Returns
- DashAIDataset
- The transformed dataset with updated DashAI column types.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.