Preprocessing minmaxscaler - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Preprocessing is 0.1.0 โ€” read its documentation.

Home โ€บ Preprocessing โ€บ Feature scaling

MinMaxScaler

Maps each feature onto a fixed range.

public sealed class MinMaxScaler

Properties โ€” FeatureCount and SampleCount are the shape it was fitted on. DataMinimum, DataMaximum and DataRange are what it saw; Scale and Minimum are what Transform multiplies and adds. None is nullable: unlike StandardScaler, every statistic here exists whatever the options say.

Example โ€” three rows, two features, the second constant.

using Lodestar.Preprocessing;

double[] samples = [1.0, 10.0, 3.0, 10.0, 5.0, 10.0];

MinMaxScaler scaler = MinMaxScaler.Fit(samples, featureCount: 2);

double scale = scaler.Scale[0];          // => 0.25
double constantScale = scaler.Scale[1];  // => 1

double[] mapped = scaler.Transform(samples);
double smallest = mapped[0];             // => 0

Remarks โ€” the first feature spans 1 to 5, so a quarter maps it onto [0, 1]. The second never varies, and its scale is 1 rather than a division by zero: the rule is range < 10ยทeps, not range == 0, which MinMaxScaler.Fit states with the measurement behind it. A feature the floor catches lands on the bottom of the range.

Applies to โ€” net10.0, netstandard2.0.

See also โ€” MinMaxScalerOptions, the feature scaling index, the Python equivalence table.

Members

Member What it does
MinMaxScaler.Fit Fits a scaler on a row-major sample matrix.
MinMaxScaler.InverseTransform Undoes Transform, and never clips.
MinMaxScaler.PartialFit Folds another batch into the fitted statistics.
MinMaxScaler.Transform Maps a matrix onto the fitted range.