Class MissingIndicator<T>
- Namespace
- AiDotNet.Preprocessing.Imputers
- Assembly
- AiDotNet.dll
Creates binary indicator features for missing values.
public class MissingIndicator<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>
Type Parameters
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
MissingIndicator<T>
- Implements
- Inherited Members
Remarks
MissingIndicator transforms a dataset by adding binary columns that indicate where values were missing. This is useful when the fact that a value is missing is itself informative for the model.
For Beginners: Sometimes knowing that data is missing is important: - A missing income might mean someone declined to answer (high income?) - A missing medical test might mean the doctor didn't think it was necessary
This transformer adds new columns (one per feature) with 1 where data was missing and 0 where it was present.
Constructors
MissingIndicator(MissingIndicatorFeatures, double, int[]?)
Creates a new instance of MissingIndicator<T>.
public MissingIndicator(MissingIndicatorFeatures features = MissingIndicatorFeatures.MissingOnly, double missingValue = NaN, int[]? columnIndices = null)
Parameters
featuresMissingIndicatorFeaturesWhich features to create indicators for. Defaults to MissingOnly.
missingValuedoubleThe value to treat as missing. Defaults to NaN.
columnIndicesint[]The column indices to check, or null for all columns.
Properties
Features
Gets which features to create indicators for.
public MissingIndicatorFeatures Features { get; }
Property Value
FeaturesWithMissing
Gets the indices of features that had missing values during fit.
public int[]? FeaturesWithMissing { get; }
Property Value
- int[]
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Identifies which features have missing values.
protected override void FitCore(Matrix<T> data)
Parameters
dataMatrix<T>The training data matrix.
GetFeatureNamesOut(string[]?)
Gets the output feature names after transformation.
public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)
Parameters
inputFeatureNamesstring[]
Returns
- string[]
InverseTransformCore(Matrix<T>)
Inverse transformation is not supported.
protected override Matrix<T> InverseTransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>
TransformCore(Matrix<T>)
Creates binary indicator features for missing values.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>The data to transform.
Returns
- Matrix<T>
Binary indicators for missing values.