impute

Fills the missing values in the dataset with one of the following strategies (see Inputs section).

Attention: Available only with Twin Activate commercial edition.

Syntax

[imputed_data, parameters] = impute(X)

[imputed_data, parameters] = impute(X, options)

Inputs

X
Input data to be imputed.
Type: double
Dimension: matrix
options
Type: struct
strategy
Strategy to be used to fill the missing values.
Allowed Values: 'mean' (default), 'median', 'most_frequent', 'constant' (constant field of options is considered).
Type: char
Dimension: string
constant
Constant number to be used to fill missing values if 'constant' is the chosen strategy (default: 0).
Type: double | integer
Dimension: scalar
cols
Columns to consider to apply imputation for.
Type: integer
Dimension: vector

Outputs

imputed_data
Imputed input records.
Type: double
Dimension: matrix
parameters
Struct containing values required by imputeTransform function used on test data.
fillers: values to be used to fill at missing places.
Type: double | integer
Dimension: struct

Example

Usage of impute

X = [1 2 3;
     NaN 3 3;
     7 6 2;
     8 NaN NaN];
[X_scaled, parameters] = impute(X); %by default strategy is 'mean';
> X_scaled
X_scaled = [Matrix] 4 x 3
1.00000 2.00000 3.00000
5.33333 3.00000 3.00000
7.00000 6.00000 2.00000
8.00000 3.66667 2.66667
> parameters
parameters = struct [
cols: [Matrix] 0 x 0
constant: 0
fillers: [Matrix] 1 x 3
5.33333 3.66667 2.66667
strategy: mean
]

Comments

Output 'parameters' can be used by imputetransform function.