private async Task <LastDetectionResult> DetectLastAsync(AnomalyDetectorClient client, Guid model_id) { Console.WriteLine("Start detect..."); List <VariableValues> variables = new List <VariableValues>(); variables.Add(new VariableValues("variables_name1", new[] { "2021-01-01 00:00:00", "2021-01-01 01:00:00", "2021-01-01 02:00:00" }, new[] { 0.0f, 0.0f, 0.0f })); variables.Add(new VariableValues("variables_name2", new[] { "2021-01-01 00:00:00", "2021-01-01 01:00:00", "2021-01-01 02:00:00" }, new[] { 0.0f, 0.0f, 0.0f })); LastDetectionRequest lastDetectionRequest = new LastDetectionRequest(variables, 1); try { Response <LastDetectionResult> response = await client.LastDetectAnomalyAsync(model_id, lastDetectionRequest).ConfigureAwait(false); if (response.GetRawResponse().Status == 200) { foreach (AnomalyState state in response.Value.Results) { Console.WriteLine(String.Format("timestamp: {}, isAnomaly: {}, score: {}.", state.Timestamp, state.Value.IsAnomaly, state.Value.Score)); } } return(response); } catch (RequestFailedException ex) { Console.WriteLine(String.Format("Last detection failed: {0}", ex.Message)); throw; } catch (Exception ex) { Console.WriteLine(String.Format("Detection error. {0}", ex.Message)); throw; } }
public virtual Response <LastDetectionResult> LastDetectAnomaly(Guid modelId, LastDetectionRequest body, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("AnomalyDetectorClient.LastDetectAnomaly"); scope.Start(); try { return(RestClient.LastDetectAnomaly(modelId, body, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <LastDetectionResult> > LastDetectAnomalyAsync(Guid modelId, LastDetectionRequest body, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("AnomalyDetectorClient.LastDetectAnomaly"); scope.Start(); try { return(await RestClient.LastDetectAnomalyAsync(modelId, body, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }