Class DecimalScaler<T>
- Namespace
- AiDotNet.Preprocessing.Scalers
- Assembly
- AiDotNet.dll
Scales features by dividing by the smallest power of 10 greater than the max absolute value.
public class DecimalScaler<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
-
DecimalScaler<T>
- Implements
- Inherited Members
Remarks
Decimal scaling transforms values to fall between -1 and 1 by dividing by an appropriate power of 10. This preserves the relative decimal positions and signs of values.
For Beginners: This scaler adjusts numbers to show them in appropriate decimal places: - If your largest value is 750, it divides everything by 1,000 - So 750 becomes 0.75, 42 becomes 0.042, etc. - All values end up between -1 and 1
This is useful when you want to keep relative sizes clear and decimal places meaningful.
Constructors
DecimalScaler(int[]?)
Creates a new instance of DecimalScaler<T>.
public DecimalScaler(int[]? columnIndices = null)
Parameters
columnIndicesint[]The column indices to scale, or null for all columns.
Properties
Scale
Gets the power-of-10 scale factor for each feature computed during fitting.
public Vector<T>? Scale { 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 power-of-10 scale factor 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 (DecimalScaler doesn't change number of features).
InverseTransformCore(Matrix<T>)
Reverses the decimal 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 decimal scaling.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>The data to transform.
Returns
- Matrix<T>
The scaled data with values between -1 and 1.