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
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
MaxAbsScaler<T>
- Implements
- 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
columnIndicesint[]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
Methods
FitCore(Matrix<T>)
Computes the maximum absolute value of 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 (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
dataMatrix<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
dataMatrix<T>The data to transform.
Returns
- Matrix<T>
The scaled data.