-
Notifications
You must be signed in to change notification settings - Fork 0
Preprocessing powermethod
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 transforming
Which power family PowerTransformer fits.
public enum PowerMethodValues — YeoJohnson is Yeo and Johnson's family, which admits zero and negative values;
scikit-learn's 'yeo-johnson', and the default. BoxCox is Box and Cox's, which needs strictly
positive values; 'box-cox'.
Example — the two exponents on the same positive column.
using Lodestar.Preprocessing;
double[] income = [22.0, 25.0, 28.0, 31.0, 35.0, 42.0, 55.0, 78.0, 120.0, 260.0];
double yeoJohnson = Math.Round(PowerTransformer.Fit(income, 1).Lambdas[0], 4); // => -0.8072
PowerTransformer fitted = PowerTransformer.Fit(
income, 1, new PowerTransformerOptions { Method = PowerMethod.BoxCox });
double boxCox = Math.Round(fitted.Lambdas[0], 4); // => -0.7802Remarks — the default is Yeo-Johnson because it always applies. Box-Cox refuses a column
holding a zero or a negative value, and refusing is the right answer there: its family is
(xᶫ − 1) / λ, which is not defined for them. Yeo-Johnson is built to extend it, applying the
Box-Cox form to the positive side and a reflected one to the negative, so a column of temperature
anomalies or profit-and-loss figures can be transformed at all.
On a strictly positive column the two are different fits, not the same fit twice. They agree on the direction and disagree on the number, as above, because the likelihoods being maximised are different functions — Yeo-Johnson's shifts each positive value by one before raising it. Prefer Box-Cox when the column is positive by construction and the exponent will be reported, since it is the family a reader will expect; prefer the default otherwise.
Applies to — net10.0, netstandard2.0.
See also — PowerTransformerOptions,
PowerTransformer.Fit.