Exemple #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            //Parse HTTP Request Body
            string    requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            HeartData data        = JsonConvert.DeserializeObject <HeartData>(requestBody);

            //Make Prediction
            //var predictionResult = ConsumerModel.Predict(data);

            HeartPrediction prediction = _predictionEnginePool.Predict(modelName: "HeartModel", example: data);

            Debug.WriteLine("WTF");


            //Convert prediction to string
            //TODO udkommenteres fordi vores prediction er en string og ikke en bool.
            //string sentiment = Convert.ToBoolean(prediction.Prediction) ? "Healthy heart" : "Unhealthy Heart";
            string sentiment = prediction.Prediction;

            //Return Prediction
            return((ActionResult) new OkObjectResult(sentiment));
        }
        // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume
        // Method for consuming model in your app
        public static HeartPrediction Predict(HeartData input)
        {
            HeartPrediction result = PredictionEngine.Value.Predict(input);

            return(result);
        }