Table of Contents

Class MaxAbsScaler<T>

Namespace
AiDotNet.Preprocessing.Scalers
Assembly
AiDotNet.dll

Scales each feature by its maximum absolute value.

public class MaxAbsScaler<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>>
MaxAbsScaler<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

Max absolute scaling transforms each feature by dividing by its maximum absolute value, resulting in features with values in the range [-1, 1]. This scaler does not shift or center the data, so it preserves sparsity.

For Beginners: This scaler divides each feature by its largest absolute value: - The largest value (positive or negative) becomes 1 or -1 - All other values are proportionally scaled - Zero values remain zero (preserves sparsity)

This is useful when:

  • You have sparse data and want to preserve zeros
  • You don't want to center your data
  • You want values bounded between -1 and 1

Constructors

MaxAbsScaler(int[]?)

Creates a new instance of MaxAbsScaler<T>.

public MaxAbsScaler(int[]? columnIndices = null)

Parameters

columnIndices int[]

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

Properties

MaxAbsolute

Gets the maximum absolute value of each feature computed during fitting.

public Vector<T>? MaxAbsolute { get; }

Property Value

Vector<T>

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Computes the maximum absolute value 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 (MaxAbsScaler doesn't change number of features).

InverseTransformCore(Matrix<T>)

Reverses the max absolute 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 max absolute scaling.

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

Parameters

data Matrix<T>

The data to transform.

Returns

Matrix<T>

The scaled data.