public ActionResult <List <SentimentPrediction> > Predict(IEnumerable <SentimentIssue> samples)
        {
            var input = samples.ToList();

            if (samples.Count() == 1)
            {
                var result = new List <SentimentPrediction>();

                result.Add(_sentimentModel.Predict(MLModels.SentimentModel, input[0]));
                return(result);
            }

            if (!samples.Any())
            {
                var extra = new List <SentimentIssue>
                {
                    new SentimentIssue {
                        Text = "This is a very rude movie"
                    },
                    new SentimentIssue {
                        Text = "Hate All Of You're Work"
                    },
                };
                input.AddRange(extra);
            }

            var results = _sentimentModel.Predict(MLModels.SentimentModel, input);

            return(Ok(results));
        }
Example #2
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
        {
            var name = context.Registration.Name;

            try
            {
                _logger.LogInformation("[HealthCheck][{healthCheckName}]", name);

                var options = _optionsMonitor.Get(name);

                var result = await Task.FromResult(_model.Predict(options.ModelName, options.SampleData));

                var json = JsonConvert.SerializeObject(result);

                var data = new Dictionary <string, object>
                {
                    { "result", json }
                };

                return(new HealthCheckResult(HealthStatus.Healthy, name, data: data));
            }
            catch (Exception ex)
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex));
            }
        }
Example #3
0
        public ActionResult <SpamPrediction> Predict(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                text = "free medicine winner! congratulations";
            }

            return(_spamModel.Predict(MLModels.SpamModel, new SpamInput {
                Message = text
            }));
        }
 public ActionResult <SpamPrediction> PredictSpam([FromQuery] string text)
 {
     return(_spamModel.Predict(new SpamInput {
         Message = text
     }));
 }
 public ActionResult <SentimentPrediction> GetSentiment(SentimentObservation input)
 {
     return(_sentimentModel.Predict(input));
 }
Example #6
0
 public ActionResult <SentimentPrediction> GetSentiment(SentimentIssue input)
 {
     return(_sentimentModel.Predict(input));
 }