Yashvj123 commited on
Commit
ca055b7
·
verified ·
1 Parent(s): 395031d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py CHANGED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+
5
+ # Load trained model
6
+ model = pickle.load(open("life_expectancy_model.pkl", "rb"))
7
+
8
+ # Streamlit UI
9
+ st.title("🌍 Life Expectancy Prediction App")
10
+
11
+ st.markdown("Enter the values below to predict the Life Expectancy.")
12
+
13
+ # Input Fields with Proper Ranges
14
+ year = st.number_input("Year", min_value=2000, max_value=2015, value=2008)
15
+ status = st.selectbox("Status (0: Developing, 1: Developed)", [0, 1])
16
+ adult_mortality = st.number_input("Adult Mortality Rate", min_value=1.0, max_value=723.0, value=144.0)
17
+ infant_deaths = st.number_input("Infant Deaths", min_value=0, max_value=1800, value=3)
18
+ alcohol = st.number_input("Alcohol Consumption", min_value=0.01, max_value=17.87, value=4.55)
19
+ percentage_expenditure = st.number_input("Percentage Expenditure", min_value=0.0, max_value=19479.91, value=738.25)
20
+ hepatitis_b = st.number_input("Hepatitis B Immunization (%)", min_value=1, max_value=99, value=83)
21
+ measles = st.number_input("Measles Cases", min_value=0, max_value=212183, value=2419)
22
+ bmi = st.number_input("BMI", min_value=1.0, max_value=87.3, value=38.3)
23
+ under_five_deaths = st.number_input("Under-Five Deaths", min_value=0, max_value=2500, value=4)
24
+ polio = st.number_input("Polio Immunization (%)", min_value=3, max_value=99, value=82)
25
+ total_expenditure = st.number_input("Total Healthcare Expenditure (%)", min_value=0.37, max_value=17.6, value=5.92)
26
+ diphtheria = st.number_input("Diphtheria Immunization (%)", min_value=2, max_value=99, value=82)
27
+ hiv_aids = st.number_input("HIV/AIDS Prevalence Rate", min_value=0.1, max_value=50.6, value=1.74)
28
+ gdp = st.number_input("GDP per Capita", min_value=1.68, max_value=119172.7, value=6611.52)
29
+ population = st.number_input("Population", min_value=34, max_value=1293859000, value=10230850)
30
+ thinness_1_19 = st.number_input("Thinness 1-19 years (%)", min_value=0.1, max_value=27.7, value=4.83)
31
+ thinness_5_9 = st.number_input("Thinness 5-9 years (%)", min_value=0.1, max_value=28.6, value=4.86)
32
+ income_composition = st.number_input("Income Composition of Resources", min_value=0.0, max_value=0.948, value=0.63)
33
+ schooling = st.number_input("Schooling (Years)", min_value=0.0, max_value=20.7, value=11.99)
34
+
35
+ # Predict button
36
+ if st.button("Predict Life Expectancy"):
37
+ features = np.array([[year, status, adult_mortality, infant_deaths, alcohol, percentage_expenditure,
38
+ hepatitis_b, measles, bmi, under_five_deaths, polio, total_expenditure,
39
+ diphtheria, hiv_aids, gdp, population, thinness_1_19, thinness_5_9,
40
+ income_composition, schooling]])
41
+
42
+ prediction = model.predict(features)[0]
43
+
44
+ st.success(f"📌 **Predicted Life Expectancy: {prediction:.2f} years**")