Table of Contents

Class MinMaxScaler<T>

Namespace
AiDotNet.Preprocessing.Scalers
Assembly
AiDotNet.dll

Scales features to a given range, typically [0, 1].

public class MinMaxScaler<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>

Type Parameters

T

The numeric type for calculations (e.g., float, double).

Inheritance
TransformerBase<T, Matrix<T>, Matrix<T>>
MinMaxScaler<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

Min-max scaling transforms features by scaling each feature to a given range. The default range is [0, 1]. The transformation is: X_scaled = (X - X_min) / (X_max - X_min) * (max - min) + min

For Beginners: This scaler squishes all your data into a specific range: - The smallest value becomes the minimum of the range (default 0) - The largest value becomes the maximum of the range (default 1) - Everything else is proportionally scaled in between

This is useful when:

  • Your algorithm requires data in a specific range
  • You want to preserve the relationships between values
  • You don't want outliers to heavily influence the scaling

Constructors

MinMaxScaler(double, double, int[]?)

Creates a new instance of MinMaxScaler<T> with a custom range.

public MinMaxScaler(double featureRangeMin, double featureRangeMax, int[]? columnIndices = null)

Parameters

featureRangeMin double

The minimum value of the target range.

featureRangeMax double

The maximum value of the target range.

columnIndices int[]

The column indices to scale, or null for all columns.

MinMaxScaler(int[]?)

Creates a new instance of MinMaxScaler<T> with default range [0, 1].

public MinMaxScaler(int[]? columnIndices = null)

Parameters

columnIndices int[]

The column indices to scale, or null for all columns.

Properties

DataMax

Gets the maximum value of each feature computed during fitting.

public Vector<T>? DataMax { get; }

Property Value

Vector<T>

DataMin

Gets the minimum value of each feature computed during fitting.

public Vector<T>? DataMin { get; }

Property Value

Vector<T>

FeatureRangeMax

Gets the maximum value of the target feature range.

public T FeatureRangeMax { get; }

Property Value

T

FeatureRangeMin

Gets the minimum value of the target feature range.

public T FeatureRangeMin { get; }

Property Value

T

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Computes the minimum and maximum of each feature from the training data.

protected override void FitCore(Matrix<T> data)

Parameters

data Matrix<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

inputFeatureNames string[]

The input feature names.

Returns

string[]

The same feature names (MinMaxScaler doesn't change number of features).

InverseTransformCore(Matrix<T>)

Reverses the min-max scaling transformation.

protected override Matrix<T> InverseTransformCore(Matrix<T> data)

Parameters

data Matrix<T>

The scaled data.

Returns

Matrix<T>

The original-scale data.

TransformCore(Matrix<T>)

Transforms the data by applying min-max scaling.

protected override Matrix<T> TransformCore(Matrix<T> data)

Parameters

data Matrix<T>

The data to transform.

Returns

Matrix<T>

The scaled data.