Spaces:
Runtime error
Runtime error
| import joblib | |
| import pandas as pd | |
| import streamlit as st | |
| model = joblib.load('dia1.joblib') | |
| def main(): | |
| st.title("💀Predicting Diabetes💀") | |
| with st.form("questionaire"): | |
| Pregnancies = st.slider('Pregnancy(times)',min_value=0,max_value=10) | |
| Age = st.slider('Age',min_value=0,max_value=100) | |
| Glucose = st.number_input('Glucose(mg/dl)') | |
| BloodPressure = st.number_input('BloodPressure(mm Hg)') | |
| SkinThickness = st.number_input('SkinThickness(mm)') | |
| Insulin = st.number_input('Insulin(mu U/ml)') | |
| Weight = st.number_input('Weight(kg)') | |
| Height = st.number_input('Height(cm)') | |
| # clicked==True only when the button is clicked | |
| clicked = st.form_submit_button("Predict Diabetes") | |
| if clicked: | |
| result=model.predict(pd.DataFrame({"Pregnancies": [Pregnancies], | |
| "Glucose": [Glucose], | |
| "BloodPressure": [BloodPressure], | |
| "SkinThickness": [SkinThickness], | |
| "Insulin": [Insulin], | |
| "BMI": [Weight / (Height/100)**2], | |
| "Age": [Age]})) | |
| result2=model.predict_proba(pd.DataFrame({"Pregnancies": [Pregnancies], | |
| "Glucose": [Glucose], | |
| "BloodPressure": [BloodPressure], | |
| "SkinThickness": [SkinThickness], | |
| "Insulin": [Insulin], | |
| "BMI": [Weight / (Height/100)**2], | |
| "Age": [Age]})) | |
| # Show prediction | |
| #sen = 'You have diabetes' if result[0]==1 else "You don't have diabetes" | |
| if result[0]==1: | |
| sen = (f'You have diabetes with a probability = {round(result2[0][1]*100,2)}%') | |
| else : | |
| sen = (f'You do not have diabetes with a probability = {round(result2[0][0]*100,2)}%') | |
| st.success(sen) | |
| # Run main() | |
| if __name__ == '__main__': | |
| main() | |