NormalizationCatalog.NormalizeGlobalContrast 메서드

정의

GlobalContrastNormalizingEstimator전역 대비 정규화를 개별적으로 적용하는 열을 정규화하는 을 만듭니다. 로 true설정 ensureZeroMean 하면 사전 처리 단계를 적용하여 지정된 열의 평균을 0 벡터로 만듭니다.

public static Microsoft.ML.Transforms.GlobalContrastNormalizingEstimator NormalizeGlobalContrast (this Microsoft.ML.TransformsCatalog catalog, string outputColumnName, string inputColumnName = default, bool ensureZeroMean = true, bool ensureUnitStandardDeviation = false, float scale = 1);
static member NormalizeGlobalContrast : Microsoft.ML.TransformsCatalog * string * string * bool * bool * single -> Microsoft.ML.Transforms.GlobalContrastNormalizingEstimator
<Extension()>
Public Function NormalizeGlobalContrast (catalog As TransformsCatalog, outputColumnName As String, Optional inputColumnName As String = Nothing, Optional ensureZeroMean As Boolean = true, Optional ensureUnitStandardDeviation As Boolean = false, Optional scale As Single = 1) As GlobalContrastNormalizingEstimator

매개 변수

catalog
TransformsCatalog

변환의 카탈로그입니다.

outputColumnName
String

의 변환에서 생성된 열의 inputColumnName이름입니다. 이 열의 데이터 형식은 입력 열의 데이터 형식과 동일합니다.

inputColumnName
String

정규화할 열의 이름입니다. 이 값으로 null설정하면 해당 값이 outputColumnName 원본으로 사용됩니다. 이 추정기는 알려진 크기의 벡터에서 작동합니다 Single.

ensureZeroMean
Boolean

이면 true정규화하기 전에 각 값에서 평균을 빼고, 그렇지 않으면 원시 입력을 사용합니다.

ensureUnitStandardDeviation
Boolean

이 경우 true결과 벡터의 표준 편차가 하나가 됩니다. 그렇지 않으면 결과 벡터의 L2-norm이 하나가 됩니다.

scale
Single

이 값으로 기능 크기를 조정합니다.

반환

예제

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.ML;
using Microsoft.ML.Data;

namespace Samples.Dynamic
{
    class NormalizeGlobalContrast
    {
        public static void Example()
        {
            // Create a new ML context, for ML.NET operations. It can be used for
            // exception tracking and logging, as well as the source of randomness.
            var mlContext = new MLContext();
            var samples = new List<DataPoint>()
            {
                new DataPoint(){ Features = new float[4] { 1, 1, 0, 0} },
                new DataPoint(){ Features = new float[4] { 2, 2, 0, 0} },
                new DataPoint(){ Features = new float[4] { 1, 0, 1, 0} },
                new DataPoint(){ Features = new float[4] { 0, 1, 0, 1} }
            };
            // Convert training data to IDataView, the general data type used in
            // ML.NET.
            var data = mlContext.Data.LoadFromEnumerable(samples);
            var approximation = mlContext.Transforms.NormalizeGlobalContrast(
                "Features", ensureZeroMean: false, scale: 2,
                ensureUnitStandardDeviation: true);

            // Now we can transform the data and look at the output to confirm the
            // behavior of the estimator. This operation doesn't actually evaluate
            // data until we read the data below.
            var tansformer = approximation.Fit(data);
            var transformedData = tansformer.Transform(data);

            var column = transformedData.GetColumn<float[]>("Features").ToArray();
            foreach (var row in column)
                Console.WriteLine(string.Join(", ", row.Select(x => x.ToString(
                    "f4"))));
            // Expected output:
            //  2.0000, 2.0000,-2.0000,-2.0000
            //  2.0000, 2.0000,-2.0000,-2.0000
            //  2.0000,-2.0000, 2.0000,-2.0000
            //- 2.0000, 2.0000,-2.0000, 2.0000
        }

        private class DataPoint
        {
            [VectorType(4)]
            public float[] Features { get; set; }
        }
    }
}

적용 대상