Maharani commited on
Commit
5373289
1 Parent(s): a348318

Delete kidney_app.py

Browse files
Files changed (1) hide show
  1. kidney_app.py +0 -102
kidney_app.py DELETED
@@ -1,102 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import numpy as np
4
- import pickle
5
- import base64
6
- import seaborn as sns
7
- import matplotlib.pyplot as plt
8
-
9
- st.write("""
10
- # Chronic Kidney Disease
11
-
12
- #Context
13
- This dataset is originally from UCI Machine Learning Repository. The objective of the dataset is to diagnostically predict whether a patient is having chronic kidney disease or not, based on certain diagnostic measurements included in the dataset.
14
-
15
- #Content
16
- The datasets consists of several medical predictor variables and one target variable, Class. Predictor variables includes Blood Pressure(Bp), Albumin(Al), etc.
17
-
18
- #Inspiration
19
- Can you build a machine learning model to accurately predict whether or not the patients in the dataset have chronic kidney disease or not?
20
- """)
21
-
22
- url_dataset = f'<a href="new_model.csv">Download Dataset CSV File</a>'
23
- st.markdown(url_dataset, unsafe_allow_html=True)
24
-
25
- def user_input_features() :
26
- Bp = st.sidebar.slider('Bp', 50.000, 180.000)
27
- Sg = st.sidebar.slider('Sg', 1.005, 1.025)
28
- Al = st.sidebar.slider('Al', 0.000, 5.000)
29
- Su = st.sidebar.slider('Su', 0.000, 5.000)
30
- Rbc = st.sidebar.slider('Rbc', 0.000, 1.000)
31
- Bu = st.sidebar.slider('Bu', 1.500, 391.000)
32
- Sc = st.sidebar.slider('Sc', 0.400, 76.000)
33
- Sod = st.sidebar.slider('Sod', 4.500, 163.000)
34
- Pot = st.sidebar.slider('Pot', 2.500, 47.000)
35
- Hemo = st.sidebar.slider('Hemo', 3.100, 17.800)
36
- Wbcc = st.sidebar.slider('Wbcc', 2200.000, 26400.000)
37
- Rbcc = st.sidebar.slider('Rbcc', 2.100, 8.000)
38
- Htn = st.sidebar.slider('Htn', 0.000, 1.000)
39
- Class = st.sidebar.slider('Class', 0.000, 1.000)
40
-
41
-
42
-
43
- data = {'Bp':[Bp],
44
- 'Sg':[Sg],
45
- 'Al':[Al],
46
- 'Su':[Su],
47
- 'Rbc':[Rbc],
48
- 'Bu':[Bu],
49
- 'Sc':[Sc],
50
- 'Sod':[Sod],
51
- 'Pot':[Pot],
52
- 'Hemo':[Hemo],
53
- 'Wbcc':[Wbcc],
54
- 'Rbcc':[Rbcc],
55
- 'Htn':[Htn],
56
- 'Class':[Class]
57
- }
58
-
59
- features = pd.DataFrame(data)
60
- return features
61
-
62
- input_df = user_input_features()
63
-
64
-
65
- kidney_raw = pd.read_csv('new_model.csv')
66
- kidney_raw.fillna(0, inplace=True)
67
- kidney = kidney_raw.drop(columns=['Class'])
68
- df = pd.concat([input_df, kidney], axis=0)
69
-
70
- df = df[:1] # Selects only the first row (the user input data)
71
- df.fillna(0, inplace=True)
72
-
73
- features = ['Bp', 'Sg', 'Al',
74
- 'Su',
75
- 'Rbc',
76
- 'Bu',
77
- 'Sc',
78
- 'Sod',
79
- 'Pot',
80
- 'Hemo',
81
- 'Wbcc',
82
- 'Rbcc',
83
- 'Htn'
84
- ]
85
-
86
- df = df[features]
87
-
88
-
89
- st.subheader('User Input features')
90
- st.write(df)
91
-
92
- load_clf = pickle.load(open('kidney_clf.pkl', 'rb'))
93
- prediction = load_clf.predict(df)
94
- prediction_proba = load_clf.predict_proba(df)
95
- kidney_labels = np.array(['Normal', 'Chronic Kidney'])
96
- st.subheader('Prediction')
97
- st.write(kidney_labels[int(prediction)])
98
- st.subheader('Prediction Probability')
99
- df_prob = pd.DataFrame(data = prediction_proba,
100
- index = ['Probability'],
101
- columns = kidney_labels)
102
- st.write(df_prob)