Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
값 유사성에 따라 문자열 집합을 그룹화합니다.
이러한 각 그룹에 대해 연산 pattern자는 , count및 representative. 가장 좋은 방법은 pattern 문자가 와일드카드를 * 나타내는 그룹을 설명합니다. 이 값은 count 그룹의 값 수이며 representative 그룹의 원래 값 중 하나입니다.
Syntax
T|reduce [kind=ReduceKind] byExpr [with [threshold=Threshold] [,characters=Characters]]
Learn more about syntax conventions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| Expr | string |
✔️ | 줄일 값입니다. |
| Threshold | real |
감소 작업을 트리거하기 위해 그룹화 조건과 일치하는 데 필요한 행의 최소 비율을 결정하는 0에서 1 사이의 값입니다. 기본값은 0.1입니다. 임계값 매개 변수는 함께 그룹화할 값에 필요한 최소 유사성 수준을 결정합니다. 임계값이 작을수록(0에 가까울수록) 더 유사한 값이 그룹화되어 더 적지만 더 유사한 그룹이 생성됩니다. 임계값이 크면(1에 가까울수록) 유사성이 낮아지고 유사도가 낮은 그룹이 더 많아집니다. 큰 입력에 대해 작은 임계값을 설정하는 것이 좋습니다. See Examples. |
|
| Characters | string |
용어 간에 구분되는 문자 목록입니다. 기본값은 모든 비-ascii 숫자 문자입니다. For examples, see Examples. | |
| ReduceKind | string |
유효한 값은 .입니다 source. 지정된 경우 source 연산자는 열을 집계하는 대신 테이블의 기존 행에 Pattern추가 Pattern 합니다. |
Returns
그룹 및 열이 있는 행 수만큼의 행이 있는 테이블입니다patterncountrepresentative. 가장 좋은 방법은 pattern 문자가 와일드카드를 나타내는 그룹 * 또는 임의의 삽입 문자열에 대한 자리 표시자를 설명하는 것입니다. 이 값은 count 그룹의 값 수이며 representative 그룹의 원래 값 중 하나입니다.
예를 들어 결과에 reduce by city 는 다음이 포함될 수 있습니다.
| Pattern | Count | Representative |
|---|---|---|
| San * | 5182 | San Bernard |
| Saint * | 2846 | Saint Lucy |
| Moscow | 3726 | Moscow |
| *-에-* | 2730 | 일대일 |
| Paris | 2716 | Paris |
Examples
이 섹션의 예제에서는 구문을 사용하여 시작하는 방법을 보여 주었습니다.
The examples in this article use publicly available tables in the help cluster, such as the
StormEventstable in the Samples database.
The examples in this article use publicly available tables, such as the
Weathertable in the Weather analytics sample gallery. 작업 영역의 테이블과 일치하도록 예제 쿼리에서 테이블 이름을 수정해야 할 수 있습니다.
다음 예제에서는 숫자 범위를 생성하고 연결된 문자열과 임의 정수를 사용하여 새 열을 만든 다음 특정 감소 매개 변수를 사용하여 새 열별로 행을 그룹화합니다. 임계값은 0.001로 설정됩니다. 즉, 연산자가 서로 매우 유사한 값을 그룹화합니다.
range x from 1 to 1000 step 1
| project MyText = strcat("MachineLearningX", tostring(toint(rand(10))))
| reduce by MyText with threshold=0.001 , characters = "X"
Output
| Pattern | Count | Representative |
|---|---|---|
| MachineLearning* | 1000 | MachineLearningX4 |
다음 예제에서는 숫자 범위를 생성하고 연결된 문자열과 임의 정수를 사용하여 새 열을 만든 다음 특정 감소 매개 변수를 사용하여 새 열별로 행을 그룹화합니다. 임계값은 0.9로 설정됩니다. 즉, 연산자가 값을 덜 엄격하게 그룹화하고 더 많은 분산을 허용합니다.
range x from 1 to 1000 step 1
| project MyText = strcat("MachineLearningX", tostring(toint(rand(10))))
| reduce by MyText with threshold=0.9 , characters = "X"
Output
결과에는 MyText 값이 행의% 90개 이상에 표시되는 그룹만 포함됩니다.
| Pattern | Count | Representative |
|---|---|---|
| MachineLearning* | 177 | MachineLearningX9 |
| MachineLearning* | 102 | MachineLearningX0 |
| MachineLearning* | 106 | MachineLearningX1 |
| MachineLearning* | 96 | MachineLearningX6 |
| MachineLearning* | 110 | MachineLearningX4 |
| MachineLearning* | 100 | MachineLearningX3 |
| MachineLearning* | 99 | MachineLearningX8 |
| MachineLearning* | 104 | MachineLearningX7 |
| MachineLearning* | 106 | MachineLearningX2 |
If the Characters parameter is unspecified, by default the operator treats all non-alphanumeric characters (including spaces and punctuation) as term separators.
The following example shows how the reduce operator behaves when the Characters parameter isn't specified.
range x from 1 to 10 step 1 | project str = strcat("foo", "Z", tostring(x)) | reduce by str
Output
| Pattern | Count | Representative |
|---|---|---|
| others | 10 |
그러나 "Z"가 구분 기호로 지정되면 str 각 값이 foo 및 tostring(x)두 개의 용어인 것처럼 표시됩니다.
range x from 1 to 10 step 1 | project str = strcat("foo", "Z", tostring(x)) | reduce by str with characters="Z"
Output
| Pattern | Count | Representative |
|---|---|---|
| foo* | 10 | fooZ1 |
다음 예제에서는 축소하기 전에 축소되는 열의 GUID를 교체하는 "삭제된" 입력에 reduce 연산자를 적용하는 방법을 보여 줍니다.
추적 테이블에서 몇 가지 레코드로 시작합니다. 그런 다음 임의의 GUID를 포함하는 텍스트 열을 줄입니다. 임의 GUID가 축소 작업을 방해하므로 모두 문자열 "GUID"로 바꿉니다. 이제 축소 작업을 수행합니다. 포함된 '-' 또는 '_' 문자가 포함된 다른 "준 임의" 식별자가 있는 경우 문자를 비기 차단기로 처리합니다.
Trace
| take 10000
| extend Text = replace(@"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}", "GUID", Text)
| reduce by Text with characters="-_"
Related content
Note
연산자의 reduce 구현은 주로 Risto Vaarandi의 이벤트 로그에서 마이닝 패턴에 대한 A 데이터 클러스터링 알고리즘을 기반으로 합니다.