@@ -33,3 +33,87 @@ export enum ImputationMethod {
33
33
PREVIOUS = 'PREVIOUS' ,
34
34
}
35
35
36
+ // Constants for field names
37
+ export const RULES_FIELD = "rules" ;
38
+ export const ACTION_FIELD = "action" ;
39
+ export const CONDITIONS_FIELD = "conditions" ;
40
+ export const FEATURE_NAME_FIELD = "feature_name" ;
41
+ export const THRESHOLD_TYPE_FIELD = "threshold_type" ;
42
+ export const OPERATOR_FIELD = "operator" ;
43
+ export const VALUE_FIELD = "value" ;
44
+
45
+ // Enums
46
+ export enum Action {
47
+ IGNORE_ANOMALY = "IGNORE_ANOMALY" , // ignore anomaly if found
48
+ }
49
+
50
+ export enum ThresholdType {
51
+ /**
52
+ * Specifies a threshold for ignoring anomalies where the actual value
53
+ * exceeds the expected value by a certain margin.
54
+ *
55
+ * Assume a represents the actual value and b signifies the expected value.
56
+ * IGNORE_SIMILAR_FROM_ABOVE implies the anomaly should be disregarded if a-b
57
+ * is less than or equal to ignoreSimilarFromAbove.
58
+ */
59
+ ACTUAL_OVER_EXPECTED_MARGIN = "ACTUAL_OVER_EXPECTED_MARGIN" ,
60
+
61
+ /**
62
+ * Specifies a threshold for ignoring anomalies where the actual value
63
+ * is below the expected value by a certain margin.
64
+ *
65
+ * Assume a represents the actual value and b signifies the expected value.
66
+ * Likewise, IGNORE_SIMILAR_FROM_BELOW
67
+ * implies the anomaly should be disregarded if b-a is less than or equal to
68
+ * ignoreSimilarFromBelow.
69
+ */
70
+ EXPECTED_OVER_ACTUAL_MARGIN = "EXPECTED_OVER_ACTUAL_MARGIN" ,
71
+
72
+ /**
73
+ * Specifies a threshold for ignoring anomalies based on the ratio of
74
+ * the difference to the actual value when the actual value exceeds
75
+ * the expected value.
76
+ *
77
+ * Assume a represents the actual value and b signifies the expected value.
78
+ * The variable IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO presumably implies the
79
+ * anomaly should be disregarded if the ratio of the deviation from the actual
80
+ * to the expected (a-b)/|a| is less than or equal to IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO.
81
+ */
82
+ ACTUAL_OVER_EXPECTED_RATIO = "ACTUAL_OVER_EXPECTED_RATIO" ,
83
+
84
+ /**
85
+ * Specifies a threshold for ignoring anomalies based on the ratio of
86
+ * the difference to the actual value when the actual value is below
87
+ * the expected value.
88
+ *
89
+ * Assume a represents the actual value and b signifies the expected value.
90
+ * Likewise, IGNORE_NEAR_EXPECTED_FROM_BELOW_BY_RATIO appears to indicate that the anomaly
91
+ * should be ignored if the ratio of the deviation from the expected to the actual
92
+ * (b-a)/|a| is less than or equal to ignoreNearExpectedFromBelowByRatio.
93
+ */
94
+ EXPECTED_OVER_ACTUAL_RATIO = "EXPECTED_OVER_ACTUAL_RATIO" ,
95
+ }
96
+
97
+ // Method to get the description of ThresholdType
98
+ export function getThresholdTypeDescription ( thresholdType : ThresholdType ) : string {
99
+ return thresholdType ; // In TypeScript, the enum itself holds the description.
100
+ }
101
+
102
+ // Enums for Operators
103
+ export enum Operator {
104
+ LTE = "LTE" ,
105
+ }
106
+
107
+ // Interfaces for Rule and Condition
108
+ export interface Rule {
109
+ action : Action ;
110
+ conditions : Condition [ ] ;
111
+ }
112
+
113
+ export interface Condition {
114
+ featureName : string ;
115
+ thresholdType : ThresholdType ;
116
+ operator : Operator ;
117
+ value : number ;
118
+ }
119
+
0 commit comments