-
Notifications
You must be signed in to change notification settings - Fork 5.1k
/
models.cadl
304 lines (257 loc) · 8.76 KB
/
models.cadl
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
import "@cadl-lang/rest";
import "@azure-tools/cadl-azure-core";
using Cadl.Http;
using Cadl.Rest;
using Azure.Core;
namespace AnomalyDetector.Univariate;
enum ImputeModeKnownValues {
Auto: "auto",
Previous: "previous",
Linear: "linear",
Fixed: "fixed",
Zero: "zero",
NotFill: "notFill",
}
@knownValues(ImputeModeKnownValues)
model ImputeMode is string;
enum AnomalyDetectorErrorCodesKnownValues {
"InvalidCustomInterval",
"BadArgument",
"InvalidGranularity",
"InvalidPeriod",
"InvalidModelArgument",
"InvalidSeries",
"InvalidJsonFormat",
"RequiredGranularity",
"RequiredSeries",
"InvalidImputeMode",
"InvalidImputeFixedValue",
}
@knownValues(AnomalyDetectorErrorCodesKnownValues)
model AnomalyDetectorErrorCodes is string;
enum TimeGranularity {
Yearly: "yearly",
Monthly: "monthly",
Weekly: "weekly",
Daily: "daily",
Hourly: "hourly",
PerMinute: "minutely",
PerSecond: "secondly",
Microsecond: "microsecond",
None: "none",
}
@doc("The request of entire or last anomaly detection.")
model DetectRequest {
@doc("""
Time series data points. Points should be sorted by timestamp in ascending
order to match the anomaly detection result. If the data is not sorted
correctly or there is duplicated timestamp, the API will not work. In such
case, an error message will be returned.
""")
series: TimeSeriesPoint[];
@doc("""
Optional argument, can be one of yearly, monthly, weekly, daily, hourly,
minutely, secondly, microsecond or none. If granularity is not present, it will
be none by default. If granularity is none, the timestamp property in time
series point can be absent.
""")
granularity?: TimeGranularity;
@doc("""
Custom Interval is used to set non-standard time interval, for example, if the
series is 5 minutes, request can be set as {\"granularity\":\"minutely\",
\"customInterval\":5}.
""")
customInterval?: int32;
@doc("""
Optional argument, periodic value of a time series. If the value is null or
does not present, the API will determine the period automatically.
""")
period?: int32;
@doc("Optional argument, advanced model parameter, max anomaly ratio in a time series.")
maxAnomalyRatio?: float32;
@doc("""
Optional argument, advanced model parameter, between 0-99, the lower the value
is, the larger the margin value will be which means less anomalies will be
accepted.
""")
sensitivity?: int32;
@doc("""
Used to specify how to deal with missing values in the input series, it's used
when granularity is not \"none\".
""")
imputeMode?: ImputeMode;
@doc("""
Used to specify the value to fill, it's used when granularity is not \"none\"
and imputeMode is \"fixed\".
""")
imputeFixedValue?: float32;
}
@doc("The definition of input timeseries points.")
model TimeSeriesPoint {
@doc("Optional argument, timestamp of a data point (ISO8601 format).")
timestamp?: zonedDateTime;
@doc("The measurement of that point, should be float.")
value: float32;
}
@doc("The response of entire anomaly detection.")
model EntireDetectResponse {
@doc("""
Frequency extracted from the series, zero means no recurrent pattern has been
found.
""")
period: int32;
@doc("""
ExpectedValues contain expected value for each input point. The index of the
array is consistent with the input series.
""")
expectedValues: float32[];
@doc("""
UpperMargins contain upper margin of each input point. UpperMargin is used to
calculate upperBoundary, which equals to expectedValue + (100 -
marginScale)*upperMargin. Anomalies in response can be filtered by
upperBoundary and lowerBoundary. By adjusting marginScale value, less
significant anomalies can be filtered in client side. The index of the array is
consistent with the input series.
""")
upperMargins: float32[];
@doc("""
LowerMargins contain lower margin of each input point. LowerMargin is used to
calculate lowerBoundary, which equals to expectedValue - (100 -
marginScale)*lowerMargin. Points between the boundary can be marked as normal
ones in client side. The index of the array is consistent with the input
series.
""")
lowerMargins: float32[];
@doc("""
IsAnomaly contains anomaly properties for each input point. True means an
anomaly either negative or positive has been detected. The index of the array
is consistent with the input series.
""")
isAnomaly: boolean[];
@doc("""
IsNegativeAnomaly contains anomaly status in negative direction for each input
point. True means a negative anomaly has been detected. A negative anomaly
means the point is detected as an anomaly and its real value is smaller than
the expected one. The index of the array is consistent with the input series.
""")
isNegativeAnomaly: boolean[];
@doc("""
IsPositiveAnomaly contain anomaly status in positive direction for each input
point. True means a positive anomaly has been detected. A positive anomaly
means the point is detected as an anomaly and its real value is larger than the
expected one. The index of the array is consistent with the input series.
""")
isPositiveAnomaly: boolean[];
@doc("""
The severity score for each input point. The larger the value is, the more
sever the anomaly is. For normal points, the \"severity\" is always 0.
""")
severity?: float32[];
}
@doc("Error information returned by the API.")
@error
model AnomalyDetectorError {
@header
"x-ms-error"?: string,
@doc("The error code.")
code?: AnomalyDetectorErrorCodes;
@doc("A message explaining the error reported by the service.")
message?: string;
}
@doc("The response of last anomaly detection.")
model LastDetectResponse {
@doc("""
Frequency extracted from the series, zero means no recurrent pattern has been
found.
""")
period: int32;
@doc("Suggested input series points needed for detecting the latest point.")
suggestedWindow: int32;
@doc("Expected value of the latest point.")
expectedValue: float32;
@doc("""
Upper margin of the latest point. UpperMargin is used to calculate
upperBoundary, which equals to expectedValue + (100 - marginScale)*upperMargin.
If the value of latest point is between upperBoundary and lowerBoundary, it
should be treated as normal value. By adjusting marginScale value, anomaly
status of latest point can be changed.
""")
upperMargin: float32;
@doc("""
Lower margin of the latest point. LowerMargin is used to calculate
lowerBoundary, which equals to expectedValue - (100 - marginScale)*lowerMargin.
""")
lowerMargin: float32;
@doc("""
Anomaly status of the latest point, true means the latest point is an anomaly
either in negative direction or positive direction.
""")
isAnomaly: boolean;
@doc("""
Anomaly status in negative direction of the latest point. True means the latest
point is an anomaly and its real value is smaller than the expected one.
""")
isNegativeAnomaly: boolean;
@doc("""
Anomaly status in positive direction of the latest point. True means the latest
point is an anomaly and its real value is larger than the expected one.
""")
isPositiveAnomaly: boolean;
@doc("""
The severity score for the last input point. The larger the value is, the more
sever the anomaly is. For normal points, the \"severity\" is always 0.
""")
severity?: float32;
}
@doc("The request of change point detection.")
model ChangePointDetectRequest {
@doc("""
Time series data points. Points should be sorted by timestamp in ascending
order to match the change point detection result.
""")
series: TimeSeriesPoint[];
@doc("""
Can only be one of yearly, monthly, weekly, daily, hourly, minutely or
secondly. Granularity is used for verify whether input series is valid.
""")
granularity: TimeGranularity;
@doc("""
Custom Interval is used to set non-standard time interval, for example, if the
series is 5 minutes, request can be set as {\"granularity\":\"minutely\",
\"customInterval\":5}.
""")
customInterval?: int32;
@doc("""
Optional argument, periodic value of a time series. If the value is null or
does not present, the API will determine the period automatically.
""")
period?: int32;
@doc("""
Optional argument, advanced model parameter, a default stableTrendWindow will
be used in detection.
""")
stableTrendWindow?: int32;
@doc("""
Optional argument, advanced model parameter, between 0.0-1.0, the lower the
value is, the larger the trend error will be which means less change point will
be accepted.
""")
threshold?: float32;
}
@doc("The response of change point detection.")
model ChangePointDetectResponse {
@doc("""
Frequency extracted from the series, zero means no recurrent pattern has been
found.
""")
@visibility("read")
period?: int32;
@doc("""
isChangePoint contains change point properties for each input point. True means
an anomaly either negative or positive has been detected. The index of the
array is consistent with the input series.
""")
isChangePoint?: boolean[];
@doc("the change point confidence of each point")
confidenceScores?: float32[];
}