RobustScaler<T>

Models & Types · AiDotNet.Preprocessing.Scalers

Scales features using statistics that are robust to outliers.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → RobustScaler<T>

For Beginners

This scaler is like StandardScaler but better handles outliers:

  • Uses median (middle value) instead of mean (average)
  • Uses IQR (spread of middle 50%) instead of standard deviation

Why this matters:

  • Mean and std are heavily influenced by extreme values
  • Median and IQR ignore extreme values

Example: If most house prices are $100K-$500K but a few are $10M, RobustScaler won’t let those mansions distort the scaling.

How It Works

Robust scaling removes the median and scales data according to the interquartile range (IQR). The IQR is the range between the 25th percentile (Q1) and 75th percentile (Q3). Unlike StandardScaler, RobustScaler uses statistics that are less affected by outliers.

Constructors

Constructor Summary
RobustScaler(bool withCentering, bool withScaling, int[] columnIndices) Creates a new instance of RobustScaler with default settings.
RobustScaler(double quantileRangeMin, double quantileRangeMax, bool withCentering, bool withScaling, int[] columnIndices) Creates a new instance of RobustScaler with custom quantile range.

Properties

Property Summary
Vector<T> InterquartileRange { get; } Gets the interquartile range (IQR) of each feature computed during fitting.
Vector<T> Median { get; } Gets the median of each feature computed during fitting.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
bool WithCentering { get; } Gets whether this scaler centers the data (subtracts median).
bool WithScaling { get; } Gets whether this scaler scales the data (divides by IQR).

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.