Esempio n. 1
0
        // POST: api/Default
        public IHttpActionResult Post(string medicalRecordJson)
        {
            MedicalRecord medicalRecordObj = JsonConvert.DeserializeObject <MedicalRecord>(medicalRecordJson);

            Classification classification = new Classification();

            // Model training can be skipped when working on pre-trained models
            FileStream modelStream = new FileStream("[Path]", FileMode.Create);

            classification.TrainModel(new MedicalRecordDataSource(), modelStream);

            double         accuracy   = classification.EvaluateModel(new MedicalRecordDataSource(), modelStream);
            double         score      = classification.Score(medicalRecordObj, modelStream);
            RiskPrediction prediction = new RiskPrediction
            {
                Score    = score,
                Accuracy = accuracy
            };

            return(Json <RiskPrediction>(prediction));
        }