Class OutlierClipper<T>
- Namespace
- AiDotNet.Preprocessing.OutlierHandling
- Assembly
- AiDotNet.dll
Clips outliers to specified percentile bounds.
public class OutlierClipper<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
-
OutlierClipper<T>
- Implements
- Inherited Members
Remarks
OutlierClipper clips values below a lower percentile and above an upper percentile to those percentile values. This reduces the impact of extreme outliers while preserving the overall data distribution.
For Beginners: Outliers are extreme values that are far from most of your data. They can distort your model's learning. Clipping replaces extreme values with more reasonable bounds: - Values below the 1st percentile → replaced with 1st percentile value - Values above the 99th percentile → replaced with 99th percentile value
Example: Income data where most people earn $30K-$200K but a few billionaires would be clipped to prevent the model from being skewed by extreme wealth.
Constructors
OutlierClipper(double, double, int[]?)
Creates a new instance of OutlierClipper<T>.
public OutlierClipper(double lowerPercentile = 1, double upperPercentile = 99, int[]? columnIndices = null)
Parameters
lowerPercentiledoubleLower percentile bound (0-100). Values below are clipped. Defaults to 1.
upperPercentiledoubleUpper percentile bound (0-100). Values above are clipped. Defaults to 99.
columnIndicesint[]The column indices to clip, or null for all columns.
Properties
LowerBounds
Gets the computed lower bounds for each feature.
public double[]? LowerBounds { get; }
Property Value
- double[]
LowerPercentile
Gets the lower percentile (values below this are clipped).
public double LowerPercentile { get; }
Property Value
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
UpperBounds
Gets the computed upper bounds for each feature.
public double[]? UpperBounds { get; }
Property Value
- double[]
UpperPercentile
Gets the upper percentile (values above this are clipped).
public double UpperPercentile { get; }
Property Value
Methods
FitCore(Matrix<T>)
Computes the percentile bounds for each feature.
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>)
Clips values to the computed percentile bounds.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>The data to transform.
Returns
- Matrix<T>
The data with outliers clipped.