Class QuantileTransformer<T>
- Namespace
- AiDotNet.Preprocessing.PowerTransforms
- Assembly
- AiDotNet.dll
Transforms features to follow a uniform or normal distribution using quantile information.
public class QuantileTransformer<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
-
QuantileTransformer<T>
- Implements
- Inherited Members
Remarks
QuantileTransformer applies a non-linear transformation that maps the input distribution to either a uniform or normal (Gaussian) distribution. This is effective at reducing the impact of outliers and normalizing non-Gaussian distributions.
For Beginners: This transformer redistributes your data to match a desired pattern: - Uniform: Spreads values evenly across [0, 1] - Normal: Creates a bell curve distribution
Example with uniform output: [1, 1, 2, 3, 5, 8, 13, 100, 1000] → [0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0] Notice how extreme values (100, 1000) no longer dominate.
Constructors
QuantileTransformer(OutputDistributionType, int, int[]?)
Creates a new instance of QuantileTransformer<T>.
public QuantileTransformer(OutputDistributionType outputDistribution = OutputDistributionType.Uniform, int nQuantiles = 1000, int[]? columnIndices = null)
Parameters
outputDistributionOutputDistributionTypeThe target distribution. Defaults to Uniform.
nQuantilesintThe number of quantiles to compute. Defaults to 1000.
columnIndicesint[]The column indices to transform, or null for all columns.
Properties
NQuantiles
Gets the number of quantiles used.
public int NQuantiles { get; }
Property Value
OutputDistribution
Gets the target output distribution.
public OutputDistributionType OutputDistribution { get; }
Property Value
Quantiles
Gets the quantiles for each feature computed during fitting.
public List<T[]>? Quantiles { get; }
Property Value
- List<T[]>
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Computes the quantiles for each feature from the training data.
protected override void FitCore(Matrix<T> data)
Parameters
dataMatrix<T>The training data matrix where each column is a feature.
GetFeatureNamesOut(string[]?)
Gets the output feature names after transformation.
public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)
Parameters
inputFeatureNamesstring[]The input feature names.
Returns
- string[]
The same feature names (QuantileTransformer doesn't change number of features).
InverseTransformCore(Matrix<T>)
Reverses the quantile transformation.
protected override Matrix<T> InverseTransformCore(Matrix<T> data)
Parameters
dataMatrix<T>The transformed data.
Returns
- Matrix<T>
The original-scale data.
TransformCore(Matrix<T>)
Transforms the data by mapping to the target distribution.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>The data to transform.
Returns
- Matrix<T>
The transformed data following the target distribution.