Skip to content

Commit

Permalink
bump mvad 07be669ac8e83c8766f10e99c59dbd2375614776 (#36166)
Browse files Browse the repository at this point in the history
* bump mvad 07be669ac8e83c8766f10e99c59dbd2375614776

* fix test case and update api / snippets
  • Loading branch information
m-nash authored May 10, 2023
1 parent 0222a0d commit 715669c
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 871 deletions.
5 changes: 3 additions & 2 deletions sdk/anomalydetector/Azure.AI.AnomalyDetector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ Console.WriteLine("Detecting anomalies in the entire time series.");

try
{
UnivariateEntireDetectionResult result = client.DetectUnivariateEntireSeries(request);
Response response = client.DetectUnivariateEntireSeries(request.ToRequestContent());
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;

bool hasAnomaly = false;
for (int i = 0; i < request.Series.Count; ++i)
{
if (result.IsAnomaly[i])
if (result.GetProperty("isAnomaly")[i].GetBoolean())
{
Console.WriteLine($"An anomaly was detected at index: {i}.");
hasAnomaly = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public AnomalyDetectorClient(System.Uri endpoint, Azure.AzureKeyCredential crede
public virtual Azure.Response DetectUnivariateChangePoint(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.AnomalyDetector.UnivariateChangePointDetectionResult>> DetectUnivariateChangePointAsync(Azure.AI.AnomalyDetector.UnivariateChangePointDetectionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DetectUnivariateChangePointAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response<Azure.AI.AnomalyDetector.UnivariateEntireDetectionResult> DetectUnivariateEntireSeries(Azure.AI.AnomalyDetector.UnivariateDetectionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DetectUnivariateEntireSeries(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.AnomalyDetector.UnivariateEntireDetectionResult>> DetectUnivariateEntireSeriesAsync(Azure.AI.AnomalyDetector.UnivariateDetectionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DetectUnivariateEntireSeriesAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response<Azure.AI.AnomalyDetector.UnivariateLastDetectionResult> DetectUnivariateLastPoint(Azure.AI.AnomalyDetector.UnivariateDetectionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DetectUnivariateLastPoint(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; }
Expand Down Expand Up @@ -230,11 +228,11 @@ public ModelState() { }
}
public partial class MultivariateBatchDetectionOptions
{
public MultivariateBatchDetectionOptions(string dataSource, int topContributorCount, System.DateTimeOffset startTime, System.DateTimeOffset endTime) { }
public MultivariateBatchDetectionOptions(string dataSource, System.DateTimeOffset startTime, System.DateTimeOffset endTime) { }
public string DataSource { get { throw null; } set { } }
public System.DateTimeOffset EndTime { get { throw null; } set { } }
public System.DateTimeOffset StartTime { get { throw null; } set { } }
public int TopContributorCount { get { throw null; } set { } }
public int? TopContributorCount { get { throw null; } set { } }
}
public partial class MultivariateBatchDetectionResultSummary
{
Expand Down Expand Up @@ -343,18 +341,6 @@ public UnivariateDetectionOptions(System.Collections.Generic.IEnumerable<Azure.A
public int? Sensitivity { get { throw null; } set { } }
public System.Collections.Generic.IList<Azure.AI.AnomalyDetector.TimeSeriesPoint> Series { get { throw null; } }
}
public partial class UnivariateEntireDetectionResult
{
internal UnivariateEntireDetectionResult() { }
public System.Collections.Generic.IReadOnlyList<float> ExpectedValues { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<bool> IsAnomaly { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<bool> IsNegativeAnomaly { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<bool> IsPositiveAnomaly { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<float> LowerMargins { get { throw null; } }
public int Period { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<float> Severity { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<float> UpperMargins { get { throw null; } }
}
public partial class UnivariateLastDetectionResult
{
internal UnivariateLastDetectionResult() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ Console.WriteLine("Detecting anomalies in the entire time series.");

try
{
UnivariateEntireDetectionResult result = client.DetectUnivariateEntireSeries(request);
Response response = client.DetectUnivariateEntireSeries(request.ToRequestContent());
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;

bool hasAnomaly = false;
for (int i = 0; i < request.Series.Count; ++i)
{
if (result.IsAnomaly[i])
if (result.GetProperty("isAnomaly")[i].GetBoolean())
{
Console.WriteLine($"An anomaly was detected at index: {i}.");
hasAnomaly = true;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,62 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<doc>
<members>
<member name="DetectUnivariateEntireSeriesAsync(UnivariateDetectionOptions,CancellationToken)">
<example>
This sample shows how to call DetectUnivariateEntireSeriesAsync with required parameters.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var options = new UnivariateDetectionOptions(new TimeSeriesPoint[]
{
new TimeSeriesPoint(3.14f)
{
Timestamp = DateTimeOffset.UtcNow,
}
})
{
Granularity = TimeGranularity.Yearly,
CustomInterval = 1234,
Period = 1234,
MaxAnomalyRatio = 3.14f,
Sensitivity = 1234,
ImputeMode = ImputeMode.Auto,
ImputeFixedValue = 3.14f,
};
var result = await client.DetectUnivariateEntireSeriesAsync(options);
]]></code>
</example>
</member>
<member name="DetectUnivariateEntireSeries(UnivariateDetectionOptions,CancellationToken)">
<example>
This sample shows how to call DetectUnivariateEntireSeries with required parameters.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var options = new UnivariateDetectionOptions(new TimeSeriesPoint[]
{
new TimeSeriesPoint(3.14f)
{
Timestamp = DateTimeOffset.UtcNow,
}
})
{
Granularity = TimeGranularity.Yearly,
CustomInterval = 1234,
Period = 1234,
MaxAnomalyRatio = 3.14f,
Sensitivity = 1234,
ImputeMode = ImputeMode.Auto,
ImputeFixedValue = 3.14f,
};
var result = client.DetectUnivariateEntireSeries(options);
]]></code>
</example>
</member>
<member name="DetectUnivariateEntireSeriesAsync(RequestContent,RequestContext)">
<example>
This sample shows how to call DetectUnivariateEntireSeriesAsync with required request content, and how to parse the result.
Expand Down Expand Up @@ -941,7 +885,10 @@ var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var options = new MultivariateBatchDetectionOptions("<dataSource>", 1234, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow);
var options = new MultivariateBatchDetectionOptions("<dataSource>", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow)
{
TopContributorCount = 1234,
};
var result = await client.DetectMultivariateBatchAnomalyAsync("<modelId>", options);
]]></code>
</example>
Expand All @@ -954,14 +901,39 @@ var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var options = new MultivariateBatchDetectionOptions("<dataSource>", 1234, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow);
var options = new MultivariateBatchDetectionOptions("<dataSource>", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow)
{
TopContributorCount = 1234,
};
var result = client.DetectMultivariateBatchAnomaly("<modelId>", options);
]]></code>
</example>
</member>
<member name="DetectMultivariateBatchAnomalyAsync(string,RequestContent,RequestContext)">
<example>
This sample shows how to call DetectMultivariateBatchAnomalyAsync with required parameters and request content and parse the result.
This sample shows how to call DetectMultivariateBatchAnomalyAsync with required parameters and request content, and how to parse the result.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var data = new {
dataSource = "<dataSource>",
startTime = "2022-05-10T14:57:31.2311892-04:00",
endTime = "2022-05-10T14:57:31.2311892-04:00",
};
Response response = await client.DetectMultivariateBatchAnomalyAsync("<modelId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("resultId").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("dataSource").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("timestamp").ToString());
]]></code>
This sample shows how to call DetectMultivariateBatchAnomalyAsync with all parameters and request content, and how to parse the result.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
Expand Down Expand Up @@ -1004,7 +976,29 @@ Console.WriteLine(result.GetProperty("results")[0].GetProperty("errors")[0].GetP
</member>
<member name="DetectMultivariateBatchAnomaly(string,RequestContent,RequestContext)">
<example>
This sample shows how to call DetectMultivariateBatchAnomaly with required parameters and request content and parse the result.
This sample shows how to call DetectMultivariateBatchAnomaly with required parameters and request content, and how to parse the result.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);
var data = new {
dataSource = "<dataSource>",
startTime = "2022-05-10T14:57:31.2311892-04:00",
endTime = "2022-05-10T14:57:31.2311892-04:00",
};
Response response = client.DetectMultivariateBatchAnomaly("<modelId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("resultId").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("dataSource").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("timestamp").ToString());
]]></code>
This sample shows how to call DetectMultivariateBatchAnomaly with all parameters and request content, and how to parse the result.
<code><![CDATA[
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
Expand Down
Loading

0 comments on commit 715669c

Please sign in to comment.