DataOperationsCatalog.FilterRowsByKeyColumnFraction 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 세트를 열 값으로 필터링합니다 KeyDataViewType .
public Microsoft.ML.IDataView FilterRowsByKeyColumnFraction (Microsoft.ML.IDataView input, string columnName, double lowerBound = 0, double upperBound = 1);
member this.FilterRowsByKeyColumnFraction : Microsoft.ML.IDataView * string * double * double -> Microsoft.ML.IDataView
Public Function FilterRowsByKeyColumnFraction (input As IDataView, columnName As String, Optional lowerBound As Double = 0, Optional upperBound As Double = 1) As IDataView
매개 변수
- input
- IDataView
입력 데이터입니다.
- columnName
- String
필터링에 사용할 열의 이름입니다.
- lowerBound
- Double
포괄 하한입니다.
- upperBound
- Double
전용 상한입니다.
반환
예제
using System;
using System.Collections.Generic;
using Microsoft.ML;
namespace Samples.Dynamic
{
/// <summary>
/// Sample class showing how to use FilterRowsByKeyColumnFraction.
/// </summary>
public static class FilterRowsByKeyColumnFraction
{
public static void Example()
{
// Create a new context for ML.NET operations. It can be used for
// exception tracking and logging,
// as a catalog of available operations and as the source of randomness.
var mlContext = new MLContext();
// Create a small dataset as an IEnumerable.
var samples = new List<DataPoint>()
{
new DataPoint(){ Age = 21 },
new DataPoint(){ Age = 40 },
new DataPoint(){ Age = 38 },
new DataPoint(){ Age = 22 },
new DataPoint(){ Age = 40 },
new DataPoint(){ Age = 40 },
new DataPoint(){ Age = 22 },
new DataPoint(){ Age = 21 }
};
// Convert training data to IDataView.
var data = mlContext.Data.LoadFromEnumerable(samples);
// Convert the uint values to KeyDataViewData
var pipeline = mlContext.Transforms.Conversion.MapValueToKey("Age");
var transformedData = pipeline.Fit(data).Transform(data);
// Before we apply a filter, examine all the records in the dataset.
var enumerable = mlContext.Data
.CreateEnumerable<DataPoint>(transformedData, reuseRowObject: true);
Console.WriteLine($"Age");
foreach (var row in enumerable)
{
Console.WriteLine($"{row.Age}");
}
// Age
//
// 1
// 2
// 3
// 4
// 2
// 2
// 4
// 1
// Now filter down to half the keys, choosing the lower half of values.
// For the keys we have the sorted values: 1 1 2 2 2 3 4 4.
// Projected in the [0, 1[ interval as per: (key - 0.5)/(Count of Keys)
// the values of the keys for our data would be:
// 0.125 0.125 0.375 0.375 0.375 0.625 0.875 0.875
// so the keys resulting from filtering in the [0, 0.5 [ interval are
// the ones with normalized values 0.125 and 0.375, respectively keys
// with values 1 and 2.
var filteredHalfData = mlContext.Data
.FilterRowsByKeyColumnFraction(transformedData, columnName: "Age",
lowerBound: 0, upperBound: 0.5);
var filteredHalfEnumerable = mlContext.Data
.CreateEnumerable<DataPoint>(filteredHalfData,
reuseRowObject: true);
Console.WriteLine($"Age");
foreach (var row in filteredHalfEnumerable)
{
Console.WriteLine($"{row.Age}");
}
// Age
//
// 1
// 2
// 2
// 2
// 1
// As mentioned above, the normalized keys are:
// 0.125 0.125 0.375 0.375 0.375 0.625 0.875 0.875
// so the keys resulting from filtering in the [0.3, 0.6 [ interval are
// the ones with normalized value 0.375, respectively key with
// value = 2.
var filteredMiddleData = mlContext.Data
.FilterRowsByKeyColumnFraction(transformedData, columnName: "Age",
lowerBound: 0.3, upperBound: 0.6);
// Look at the data and observe that values above 2 have been filtered
// out
var filteredMiddleEnumerable = mlContext.Data
.CreateEnumerable<DataPoint>(filteredMiddleData,
reuseRowObject: true);
Console.WriteLine($"Age");
foreach (var row in filteredMiddleEnumerable)
{
Console.WriteLine($"{row.Age}");
}
// Age
//
// 2
// 2
// 2
}
private class DataPoint
{
public uint Age { get; set; }
}
}
}
설명
범위 조건을 충족하는 행만 유지합니다. 키 열 columnName
의 값(전체 키 범위의 분수로 처리됨)은(포함) 및 upperBound
(배타적) 사이 lowerBound
여야 합니다. 이 필터링은 일부 '안정적인 임의 columnName
화'(예: 해시)에서 가져온 키 열인 경우에 유용합니다.
적용 대상
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기