Preprocessing 0.2.0 powermethod - CyrilB1531/lodestar GitHub Wiki
Lodestar.Preprocessing 0.2.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
PowerMethod
Which power family PowerTransformer fits.
public enum PowerMethod
Values โ 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.7802
Remarks โ 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.