Skip to content

Commit

Permalink
Merge pull request #26 from Azure-Samples/pafarley-updates
Browse files Browse the repository at this point in the history
add scenarios
  • Loading branch information
PatrickFarley committed Sep 4, 2020
2 parents f4a27f0 + b9353bb commit deb2909
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions quickstarts/sdk/csharp-sdk-sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Program{

EntireDetectSampleAsync(client, request).Wait(); // Async method for batch anomaly detection
LastDetectSampleAsync(client, request).Wait(); // Async method for analyzing the latest data point in the set
DetectChangePoint(client, request).Wait(); // Async method for change point detection

Console.WriteLine("\nPress ENTER to exit.");
Console.ReadLine();
Expand Down Expand Up @@ -146,5 +147,32 @@ static async Task LastDetectSampleAsync(IAnomalyDetectorClient client, Request r
}
}
// </latestPointExample>

// <changePointExample>
public async Task DetectChangePoint(IAnomalyDetectorClient client, Request request)
{
Console.WriteLine("Detecting the change points in the series.");

ChangePointDetectResponse result = await client.DetectChangePointAsync(request).ConfigureAwait(false);

if (result.IsChangePoint.Contains(true))
{
Console.WriteLine("A change point was detected at index:");
for (int i = 0; i < request.Series.Count; ++i)
{
if (result.IsChangePoint[i])
{
Console.Write(i);
Console.Write(" ");
}
}
Console.WriteLine();
}
else
{
Console.WriteLine("No change point detected in the series.");
}
}
// </changePointExample>
}
}
22 changes: 22 additions & 0 deletions quickstarts/sdk/python-sdk-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,25 @@
else:
print('The latest point is not detected as anomaly.')
# </latestPointDetection>

# Detect change points

# <changePointDetection>

print('Detecting change points in the entire time series.')

try:
response = client.detect_change_point(request)
except AnomalyDetectorError as e:
print('Error code: {}'.format(e.error.code), 'Error message: {}'.format(e.error.message))
except Exception as e:
print(e)

if any(response.is_change_point):
print('An change point was detected at index:')
for i, value in enumerate(response.is_change_point):
if value:
print(i)
else:
print('No change point were detected in the time series.')
# </changePointDetection>

0 comments on commit deb2909

Please sign in to comment.