public class StandardScaler<T extends AbstractFloat = Float>
Learns per-feature training statistics and reuses them on new observations. Inputs are two-dimensional [samples, features] floating tensors. Centering and population-standard-deviation scaling are enabled by default. A constant feature uses scale one, so its training values become zero when centered. Statistics use Double; output storage keeps T, including physical FP16. Instances must not be fitted concurrently with fit/transform calls.
scaler = StandardScaler<Float>()
xTrain = scaler.fitTransform(xTrain, inPlace=true)
xTest = scaler.transform(xTest, inPlace=true)
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | isFittedisFitted as Boolean |
Whether fit has completed successfully. |
| public readonly property | mean | Immutable applied offsets, cached until the next successful fit. |
| public readonly property | scale | Immutable applied divisors; one for constants or disabled scaling. |
| public readonly property | withMeanwithMean as Boolean |
Whether to subtract training means. |
| public readonly property | withStdwithStd as Boolean |
Whether to divide by training standard deviations. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | StandardScalerStandardScaler(withMean as Boolean = true, withStd as Boolean = true) |
Configures centering and scaling independently, without fitting data. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | fitfit(notnull data as NDArray<T>) as StandardScaler<T> |
Fits on training observations only. |
| public | fitTransform | Fits training statistics, then applies them using transform's copy policy. |
| public | inverseTransform | Applies x * trainingScale + trainingMean with the same copy policy. |
| public | transform | Applies (x - trainingMean) / trainingScale using one fused buffer pass. |