/// <summary> /// Takes column filled with a vector of floats and normalize its <paramref name="norm"/> to one. By setting <paramref name="ensureZeroMean"/> to <see langword="true"/>, /// a pre-processing step would be applied to make the specified column's mean be a zero vector. /// </summary> /// <param name="catalog">The transform's catalog.</param> /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param> /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param> /// <param name="norm">Type of norm to use to normalize each sample. The indicated norm of the resulted vector will be normalized to one.</param> /// <param name="ensureZeroMean">If <see langword="true"/>, subtract mean from each value before normalizing and use the raw input otherwise.</param> /// <remarks> /// This transform performs the following operation on a each row X: Y = (X - M(X)) / D(X) /// where M(X) is scalar value of mean for all elements in the current row if <paramref name="ensureZeroMean"/>set to <see langword="true"/> or <value>0</value> othewise /// and D(X) is scalar value of selected <paramref name="norm"/>. /// </remarks> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[NormalizeLpNorm](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/NormalizeLpNorm.cs)] /// ]]> /// </format> /// </example> public static LpNormNormalizingEstimator NormalizeLpNorm(this TransformsCatalog catalog, string outputColumnName, string inputColumnName = null, LpNormNormalizingEstimatorBase.NormFunction norm = LpNormNormalizingEstimatorBase.Defaults.Norm, bool ensureZeroMean = LpNormNormalizingEstimatorBase.Defaults.LpEnsureZeroMean) => new LpNormNormalizingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, norm, ensureZeroMean);
public Reconciler(LpNormNormalizingEstimatorBase.NormFunction norm, bool ensureZeroMean) { _norm = norm; _ensureZeroMean = ensureZeroMean; }
/// <include file='../Microsoft.ML.Transforms/doc.xml' path='doc/members/member[@name="LpNormalize"]/*'/> /// <param name="input">The column containing the vectors to apply the normalization to.</param> /// <param name="norm">Type of norm to use to normalize each sample.</param> /// <param name="ensureZeroMean">Subtract mean from each value before normalizing.</param> public static Vector <float> NormalizeLpNorm(this Vector <float> input, LpNormNormalizingEstimatorBase.NormFunction norm = LpNormNormalizingEstimatorBase.Defaults.Norm, bool ensureZeroMean = LpNormNormalizingEstimatorBase.Defaults.LpEnsureZeroMean) => new OutPipelineColumn(input, norm, ensureZeroMean);
public OutPipelineColumn(Vector <float> input, LpNormNormalizingEstimatorBase.NormFunction norm, bool ensureZeroMean) : base(new Reconciler(norm, ensureZeroMean), input) { Input = input; }