Problem
This problem is centered around predicting whether a person is suffering from Chronic Kidney Disease or not. It is very important for doctors to diagnose Chronic Kidney Disease in patients so that proper treatment can be started.
The input dataset of Chronic Kidney Disease contains 25 attributes having 400 instances of patient data which can be collected nearly in 2 months of period.
Dataset
The dataset is originally sourced from Dr P. Soundarapandian M.D, D.M (Senior Consultant Nephrologist), Apollo Hospitals, India on July 2015.
Attribute Information
- age - age in years
- bp - blood pressure in mm/Hg
- sg - specific gravity - (1.005,1.010,1.015,1.020,1.025)
- al - albumin - (0,1,2,3,4,5)
- su - sugar - (0,1,2,3,4,5)
- rbc - red blood cells - (normal,abnormal)
- pc - pus cell - (normal,abnormal)
- pcc - pus cell clumps - (normal,abnormal)
- ba - bacteria - (present,notpresent)
- bgr - blood glucose random - mgs/dl
- bu - blood urea in mgs/dl
- sc - serum creatinine mgs/dl
- sod - sodium mEq/L
- pot - potassium mEq/L
- hemo - hemoglobin in gms
- pcv - packed cell volume
- wc - white blood cell count in cells/cumm
- rc - red blood cell count in million/cmm
- htn - hypertension - (yes, no)
- dm - diabetes mellitus - (yes, no)
- cad - coronary artery disease - (yes, no)
- appet - appetite - (good, poor)
- pe - pedal edema - (yes, no)
- ane - anemia - (yes, no)
- class - class - (ckd, notckd)
Solution
To solve this problem, first, we will build an ML model. Then we will train the model on existing data, evaluate how good it is, and lastly, we'll consume the model to predict our evaluation.

Prerequisites
- Visual Studio 2017 15.9.12 or later (I'm using VS2019)
- ML.NET Model Builder
- Chronic Kidney Disease dataset in CSV file with no empty or null values.
Let's start,
- Download and Install ML.NET Model Builder tool from Visual Studio Marketplace. Click Here
- After ML.NET Model Builder installation open your Visual Studio (in my case I'm using VS2019)

- Enter the project name and click on the Create button.

- Select ASP.NET Web Application (Model View Controller).

- Our Asp.NET Core MVC Web Application has been created successfully. Now we are going to build, train and evaluate our model using ML.NET Model Builder.
- Right-Click on the project and Select Add>Machine Learning.

- ML.NET Model Builder window will be shown. Now select custom scenario because we are going to build our model from our Chronic Kidney Disease dataset.

- After scenario selection, we will select the data set that will be used to train our model. You may add data from the file as well as using SQL Server Database. I will use chronic_kidney_disease_data.csv data to train my model. Originally I've downloaded this dataset from UCI Machine Learning Repo Kidney Disease Prediction Evaluation Dataset. You can download it from here. Select class column for prediction label and select input columns, after that click on Train link,

- After data source selection, enter the time for which you want to train the model and click on Start training button, and the model training will be started for the entered time.

- After the model has been successfully trained click on the evaluation button.
- In evaluating tab you can see the output details of model builder showing the best algorithm and other performance measures of the ML model.
- We can also predict the Car evaluation in ML.NET Model builder. Add your data and click on the Predict button to see the predicted evaluation from the trained ML model.
- You can see the new build machine learning model evaluation. Click on code button to consume the model into your project.

- As you can see in solution explorer, the ML.NET Machine Learning model has been created.

- Now we need to create a new controller named "KidneyDiseasePrediction" and paste the below snippet code.
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Chronic_Kidney_Disease_PredictionML.Model;
- namespace Chronic_Kidney_Disease_Prediction.Controllers
- {
- public class KidneyDiseasePredictionController : Controller
- {
- private readonly ILogger<KidneyDiseasePredictionController> _logger;
- public KidneyDiseasePredictionController(ILogger<KidneyDiseasePredictionController> logger)
- {
- _logger = logger;
- }
- public IActionResult Index()
- {
- return View();
- }
- [HttpPost]
- public IActionResult Index(ModelInput input)
- {
- ModelOutput prediction=ConsumeModel.Predict(input);
- ViewBag.Result = prediction;
- return View();
- }
- }
- }
Add a new view named Index in Views>KidneyDiseasePrediction Folder and copy the snippet code.


usman azadPosted Feb 22, 2020, 2:06 AM
Thanks,Can we predict this disease in Asp.net mvc?
Ehsan SajjadPosted Jan 6, 2020, 10:59 PM
Thanks for putting in the efforts to explore and write this!
Sourav Kumar DasPosted Jan 2, 2020, 6:24 AM
Nice and useful article Sir.
Safyan YaqoobPosted Dec 31, 2019, 11:21 AM
Interesting
Dipa MehtaPosted Dec 30, 2019, 12:39 PM
Interesting article...
Ankur MistryPosted Dec 30, 2019, 10:03 AM
Awesome thank you for sharing