public static async Task RunAsync(string endpoint, string key) { Console.WriteLine("Sample of detecting whether the latest point in series is anomaly."); IAnomalyDetectorClient client = new AnomalyDetectorClient(new ApiKeyServiceClientCredentials(key)) { Endpoint = endpoint }; // Detection Request request = Program.GetRequest(); request.MaxAnomalyRatio = 0.25; request.Sensitivity = 95; LastDetectResponse result = await client.LastDetectAsync(request).ConfigureAwait(false); if (result.IsAnomaly) { Console.WriteLine("The latest point is detected as anomaly."); } else { Console.WriteLine("The latest point is not detected as anomaly."); } }
public static async Task RunAsync(string endpoint, string key) { Console.WriteLine("Sample of detecting whether the latest point in series is anomaly."); IAnomalyDetectorClient client = new AnomalyDetectorClient(new ApiKeyServiceClientCredentials(key)) { Endpoint = endpoint }; // Create time series var series = new List <Point> { new Point(DateTime.Parse("1962-01-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-02-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-03-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-04-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-05-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-06-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-07-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-08-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-09-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-10-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-11-01T00:00:00Z"), 1), new Point(DateTime.Parse("1962-12-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-01-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-02-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-03-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-04-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-05-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-06-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-07-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-08-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-09-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-10-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-11-01T00:00:00Z"), 1), new Point(DateTime.Parse("1963-12-01T00:00:00Z"), 0) }; // Detection Request request = new Request(series, Granularity.Monthly); request.MaxAnomalyRatio = 0.25; request.Sensitivity = 95; LastDetectResponse result = await client.LastDetectAsync(request).ConfigureAwait(false); if (result.IsAnomaly) { Console.WriteLine("The latest point is detected as anomaly."); } else { Console.WriteLine("The latest point is not detected as anomaly."); } }
static async Task LastDetectSampleAsync(string endpoint, string key, Request request) { Console.WriteLine("Sample of detecting whether the latest point in series is anomaly."); IAnomalyDetectorClient client = new AnomalyDetectorClient(new ApiKeyServiceClientCredentials(key)) { Endpoint = endpoint }; LastDetectResponse result = await client.LastDetectAsync(request).ConfigureAwait(false); if (result.IsAnomaly) { Console.WriteLine("The latest point is detected as anomaly."); } else { Console.WriteLine("The latest point is not detected as anomaly."); } }