SimpleImputer¶
Replace missing values with the given strategy.
Parent type: TableTransformer
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy |
Strategy |
The strategy used to impute missing values. | - |
selector |
union<List<String>, String?> |
The list of columns used to fit the transformer. If None, all columns are used. |
null |
valueToReplace |
union<Float, String?> |
The value that should be replaced. | null |
Examples:
pipeline example {
val table = Table({"a": [1, null], "b": [3, 4]});
val imputer = SimpleImputer(SimpleImputer.Strategy.Mean, selector = "a").fit(table);
val transformedTable = imputer.transform(table);
// Table({"a": [1, 1], "b": [3, 4]})
}
pipeline example {
val table = Table({"a": [1, null], "b": [3, 4]});
val imputer = SimpleImputer(SimpleImputer.Strategy.Constant(0), selector = "a").fit(table);
val transformedTable = imputer.transform(table);
// Table({"a": [1, 0], "b": [3, 4]})
}
Stub code in SimpleImputer.sdsstub
isFitted¶
Whether the transformer is fitted.
Type: Boolean
strategy¶
The strategy used to replace missing values.
Type: Strategy
valueToReplace¶
The value that should be replaced.
Type: Any
fit¶
Learn a transformation for a set of columns in a table.
This transformer is not modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table |
Table |
The table used to fit the transformer. | - |
Results:
| Name | Type | Description |
|---|---|---|
fittedTransformer |
SimpleImputer |
The fitted transformer. |
Stub code in SimpleImputer.sdsstub
fitAndTransform¶
Learn a transformation for a set of columns in a table and apply the learned transformation to the same table.
Note: Neither this transformer nor the given table are modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table |
Table |
The table used to fit the transformer. The transformer is then applied to this table. | - |
Results:
| Name | Type | Description |
|---|---|---|
fittedTransformer |
SimpleImputer |
The fitted transformer. |
transformedTable |
Table |
The transformed table. |
Stub code in SimpleImputer.sdsstub
transform¶
Apply the learned transformation to a table.
Note: The given table is not modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table |
Table |
The table to which the learned transformation is applied. | - |
Results:
| Name | Type | Description |
|---|---|---|
transformedTable |
Table |
The transformed table. |
Stub code in TableTransformer.sdsstub
Strategy¶
Various strategies to replace missing values.
Stub code in SimpleImputer.sdsstub
Constant¶
Replace missing values with the given constant value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
Any |
The value to replace missing values. | - |
Mean¶
Replace missing values with the mean of each column.
Median¶
Replace missing values with the median of each column.
Mode¶
Replace missing values with the mode of each column.