forked from apple/ml-hierarchical-confusion-matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
specification.ts
60 lines (53 loc) · 1.43 KB
/
specification.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* For licensing see accompanying LICENSE file.
*
* Copyright (C) 2022 Apple Inc. All Rights Reserved.
*/
// TODO: Support more complex queries later on.
export interface Condition {
qualifier: 'actual' | 'observed';
label: string,
is: string,
}
export type Measure = 'count'
| 'precision'
| 'recall'
| 'accuracy'
| 'countActual'
| 'countObserved'
| 'truePositives'
| 'trueNegatives'
| 'falsePositives'
| 'falseNegatives';
export type Normalization = 'total' | 'row' | 'column';
export type Encoding = 'size' | 'color';
export interface Spec extends Defaults {
classes: Array<string>;
where?: Condition // TODO: Add multiple conditionals ombined using AND back in.
filter?: Array<string>; // Filters are combined using OR.
}
export interface Defaults {
normalization: Normalization;
encoding: Encoding;
collapsed: Array<string>;
measures: Array<Measure>;
}
export const defaults: Defaults = {
normalization: 'total',
encoding: 'color',
collapsed: [],
measures: [
'precision',
'recall',
'accuracy',
// 'countActual',
// 'countObserved',
// 'truePositives',
// 'trueNegatives',
// 'falsePositives',
// 'falseNegatives',
],
};
// TODO: Create a state object that takes care of internal representation.
// Then, we would only need methods to convert between that class and `Spec`.
// This state object could also hold the data.