Example #1
0
        public async Task <CNTKGraphModelOutput> EvaluateAsync(CNTKGraphModelInput input)
        {
            CNTKGraphModelOutput        output  = new CNTKGraphModelOutput();
            LearningModelBindingPreview binding = new LearningModelBindingPreview(learningModel);

            binding.Bind("Input3", input.Input3);
            binding.Bind("Softmax99_Output_0", output.Softmax99_Output_0);
            LearningModelEvaluationResultPreview evalResult = await learningModel.EvaluateAsync(binding, string.Empty);

            return(output);
        }
Example #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Bind model input
                ModelInput.Input3 = new List <float>();
                foreach (var n in GetThalValue())
                {
                    ModelInput.Input3.Add(n);
                }

                foreach (var n in GetChestPainType())
                {
                    ModelInput.Input3.Add(n);
                }

                ModelInput.Input3.Add(GetMajorVesselsNumber());
                ModelInput.Input3.Add(GetSTDepByExercise());
                ModelInput.Input3.Add(GetAnginaByExercise());
                ModelInput.Input3.Add(GetMaxHeartRate());

                foreach (var n in GetExerciseSlope())
                {
                    ModelInput.Input3.Add(n);
                }

                ModelInput.Input3.Add(GetAge());

                //Evaluate the model
                ModelOutput = await ModelGen.EvaluateAsync(ModelInput);

                //Iterate through evaluation output to determine highest probability digit
                float maxProb  = 0;
                int   maxIndex = 0;
                for (int i = 0; i < ModelOutput.Softmax99_Output_0.Count; i++)
                {
                    if (ModelOutput.Softmax99_Output_0[i] > maxProb)
                    {
                        maxIndex = i;
                        maxProb  = ModelOutput.Softmax99_Output_0[i];
                    }
                }

                Debug.WriteLine("Yes: {0:0.00}%, No: {1:0.00}%", ModelOutput.Softmax99_Output_0[0] * 100, ModelOutput.Softmax99_Output_0[1] * 100);

                var percentage = ModelOutput.Softmax99_Output_0[0] * 100;
                textBlockResult.Text = String.Format("Probability of Heart Disease is {0:0.00}%", percentage);
                icon.Text            = (maxIndex == 0) ? "😧" : "😃";
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }