KernelExpansionCatalog.ApproximatedKernelMap 메서드

정의

ApproximatedKernelMappingEstimator 내부 제품이 시프트 고정 커널 함수와 근사치인 낮은 차원 기능 공간에 입력 벡터를 매핑하는 항목을 만듭니다.

public static Microsoft.ML.Transforms.ApproximatedKernelMappingEstimator ApproximatedKernelMap (this Microsoft.ML.TransformsCatalog catalog, string outputColumnName, string inputColumnName = default, int rank = 1000, bool useCosAndSinBases = false, Microsoft.ML.Transforms.KernelBase generator = default, int? seed = default);
static member ApproximatedKernelMap : Microsoft.ML.TransformsCatalog * string * string * int * bool * Microsoft.ML.Transforms.KernelBase * Nullable<int> -> Microsoft.ML.Transforms.ApproximatedKernelMappingEstimator
<Extension()>
Public Function ApproximatedKernelMap (catalog As TransformsCatalog, outputColumnName As String, Optional inputColumnName As String = Nothing, Optional rank As Integer = 1000, Optional useCosAndSinBases As Boolean = false, Optional generator As KernelBase = Nothing, Optional seed As Nullable(Of Integer) = Nothing) As ApproximatedKernelMappingEstimator

매개 변수

catalog
TransformsCatalog

변환의 카탈로그입니다.

outputColumnName
String

의 변환에서 생성된 열의 inputColumnName이름입니다. 이 열의 데이터 형식은 알려진 크기의 벡터입니다 Single.

inputColumnName
String

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

rank
Int32

입력을 매핑할 기능 공간의 차원입니다.

useCosAndSinBases
Boolean

경우 truecos 및 sin basis 함수를 모두 사용하여 임의의 푸리에 빈도마다 두 가지 기능을 만듭니다. 그렇지 않으면 cos 베이스만 사용됩니다. 설정 true하면 출력 기능 공간의 차원이 2*rank가 됩니다.

generator
KernelBase

사용할 커널을 나타내는 인수입니다. 사용 가능한 두 구현은 다음과 같습니다 GaussianKernelLaplacianKernel.

seed
Nullable<Int32>

새 기능을 생성하기 위한 난수 생성기의 시드입니다(지정되지 않은 경우 전역 임의가 사용됨).

반환

예제

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

namespace Samples.Dynamic
{
    public static class ApproximatedKernelMap
    {
        // Transform feature vector to another non-linear space. See
        // https://people.eecs.berkeley.edu/~brecht/papers/07.rah.rec.nips.pdf.
        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[7] { 1, 1, 0, 0, 1, 0, 1} },
                new DataPoint(){ Features = new float[7] { 0, 0, 1, 0, 0, 1, 1} },
                new DataPoint(){ Features = new float[7] {-1, 1, 0,-1,-1, 0,-1} },
                new DataPoint(){ Features = new float[7] { 0,-1, 0, 1, 0,-1,-1} }
            };
            // Convert training data to IDataView, the general data type used in
            // ML.NET.
            var data = mlContext.Data.LoadFromEnumerable(samples);
            // ApproximatedKernel map takes data and maps it's to a random
            // low -dimensional space.
            var approximation = mlContext.Transforms.ApproximatedKernelMap(
                "Features", rank: 4, generator: new GaussianKernel(gamma: 0.7f),
                seed: 1);

            // 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:
            // -0.0119, 0.5867, 0.4942,  0.7041
            //  0.4720, 0.5639, 0.4346,  0.2671
            // -0.2243, 0.7071, 0.7053, -0.1681
            //  0.0846, 0.5836, 0.6575,  0.0581
        }

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

    }
}

적용 대상