예제 #1
0
 /// <summary>
 /// Takes column filled with a vector of floats and normazlize its <paramref name="normKind"/> 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="normKind">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>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 /// [!code-csharp[LpNormalize](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ProjectionTransforms.cs?range=1-6,12-112)]
 /// ]]>
 /// </format>
 /// </example>
 public static LpNormalizingEstimator LpNormalize(this TransformsCatalog catalog, string outputColumnName, string inputColumnName = null,
                                                  LpNormalizingEstimatorBase.NormFunction normKind = LpNormalizingEstimatorBase.Defaults.Norm, bool ensureZeroMean = LpNormalizingEstimatorBase.Defaults.LpEnsureZeroMean)
 => new LpNormalizingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, normKind, ensureZeroMean);
 public Reconciler(LpNormalizingEstimatorBase.NormFunction normKind, bool ensureZeroMean)
 {
     _norm           = normKind;
     _ensureZeroMean = ensureZeroMean;
 }
 /// <include file='../Microsoft.ML.Transforms/doc.xml' path='doc/members/member[@name="LpNormalize"]/*'/>
 /// <param name="input">The column to apply to.</param>
 /// <param name="normKind">Type of norm to use to normalize each sample.</param>
 /// <param name="subMean">Subtract mean from each value before normalizing.</param>
 public static Vector <float> LpNormalize(this Vector <float> input,
                                          LpNormalizingEstimatorBase.NormFunction normKind = LpNormalizingEstimatorBase.Defaults.Norm,
                                          bool subMean = LpNormalizingEstimatorBase.Defaults.LpEnsureZeroMean) => new OutPipelineColumn(input, normKind, subMean);
 public OutPipelineColumn(Vector <float> input, LpNormalizingEstimatorBase.NormFunction norm, bool ensureZeroMean)
     : base(new Reconciler(norm, ensureZeroMean), input)
 {
     Input = input;
 }