ibrahimnomad
commited on
Commit
•
e664774
1
Parent(s):
c643726
Upload 4 files
Browse files- Logistic_Regression_model.pkl +3 -0
- Random_Forest_model.pkl +3 -0
- app.py +50 -0
- requirements.txt +3 -0
Logistic_Regression_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e15a031bd903126b88722cbcf4516dd8ce5fc80eb391b129cd921f999680cfbb
|
3 |
+
size 886
|
Random_Forest_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c31e65ba7d64634fe23d82094b153405892ebba4efdeec0f60831292ff12e9d8
|
3 |
+
size 507816
|
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
# Load pre-trained models
|
6 |
+
models = {}
|
7 |
+
with open('Logistic_Regression_model.pkl', 'rb') as f:
|
8 |
+
models['Logistic Regression'] = pickle.load(f)
|
9 |
+
|
10 |
+
with open('Random_Forest_model.pkl', 'rb') as f:
|
11 |
+
models['Random Forest'] = pickle.load(f)
|
12 |
+
|
13 |
+
def predict_kidney_stone(gravity, ph, osmo, cond, urea, calc):
|
14 |
+
data = {'gravity': [gravity], 'ph': [ph], 'osmo': [osmo], 'cond': [cond], 'urea': [urea], 'calc': [calc]} # Include 'calc' in the data
|
15 |
+
test_df = pd.DataFrame(data)
|
16 |
+
|
17 |
+
# Predict using the combined models
|
18 |
+
y_pred_lr = models['Logistic Regression'].predict_proba(test_df)[:, 1]
|
19 |
+
y_pred_rf = models['Random Forest'].predict_proba(test_df)[:, 1]
|
20 |
+
|
21 |
+
combined_prediction = (y_pred_lr + y_pred_rf) / 2
|
22 |
+
|
23 |
+
return combined_prediction[0]
|
24 |
+
|
25 |
+
# Streamlit app
|
26 |
+
import streamlit as st
|
27 |
+
|
28 |
+
st.title('Kidney Stone Detection 🧪')
|
29 |
+
st.write('This app predicts whether a tabular kidney stone is present or not based on input values.')
|
30 |
+
st.image('https://www.health.com/thmb/vU7eqqoH-LmfHlX4WlPu9t-LyN8=/2000x0/filters:no_upscale():max_bytes(150000):strip_icc()/kindney-disease-causes-GettyImages-1257900987-03002a7b6e244dfaaecfacf4bae2f707.jpg', use_column_width=True)
|
31 |
+
st.write('Gravity: Indicates urine concentration; higher values increase stone risk.(1 - 1.1)')
|
32 |
+
st.write('pH: Measures urine acidity; extremes can promote specific stone types. (0-14)')
|
33 |
+
st.write('Osmo: Reflects urine solute concentration; higher values raise stone risk.(0-2000)')
|
34 |
+
st.write('Cond: Indicates urine ion concentration; higher values suggest increased stone risk.(0-50)')
|
35 |
+
st.write('Urea: Waste product from protein metabolism; high levels can raise stone risk.(0-1000)')
|
36 |
+
st.write('Calc: Essential mineral; excessive levels can increase certain stone types risk.(0-50)')
|
37 |
+
|
38 |
+
|
39 |
+
# Input form
|
40 |
+
gravity = st.number_input('Gravity', min_value=0.0, max_value=2.0, step=0.001, value=1.021)
|
41 |
+
ph = st.number_input('pH', min_value=0.0, max_value=14.0, step=0.1, value=4.91)
|
42 |
+
osmo = st.number_input('Osmo', min_value=0, max_value=2000, step=1, value=442)
|
43 |
+
cond = st.number_input('Cond', min_value=0.0, max_value=50.0, step=0.1, value=20.8)
|
44 |
+
urea = st.number_input('Urea', min_value=0, max_value=1000, step=1, value=398)
|
45 |
+
calc = st.number_input('Calc', min_value=0.0, max_value=50.0, step=1.0, value=6.63)
|
46 |
+
|
47 |
+
# Predict
|
48 |
+
if st.button('Predict'):
|
49 |
+
prediction = predict_kidney_stone(gravity, ph, osmo, cond, urea, calc)
|
50 |
+
st.write(f'Predicted Probability of Kidney Stone is: {prediction:.4f}%')
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
pickle
|
3 |
+
scikit-learn
|