예제 #1
0
        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;
            }
        }
예제 #2
0
 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;
     }
 }
예제 #3
0
 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;
     }
 }