elifsara commited on
Commit
e383a1d
1 Parent(s): 059e828

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +68 -0
  2. obesity.pkl +3 -0
  3. preprocessor.pkl +3 -0
  4. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import numpy as np
4
+ import pandas as pd
5
+ from sklearn.preprocessing import LabelEncoder
6
+
7
+ # Veri ön işleme nesnesini dosyadan yükleme
8
+ with open('preprocessor.pkl', 'rb') as f:
9
+ preprocessor = pickle.load(f)
10
+
11
+ # Modeli dosyadan yükleme
12
+ with open('obesity.pkl', 'rb') as f:
13
+ model = pickle.load(f)
14
+
15
+
16
+
17
+ # Uygulama başlığı ve açıklama
18
+ st.title("Obesity Risk Classifier")
19
+ st.write("Calculate your obesity risk here! Because who doesn't want to procrastinate starting a diet?")
20
+
21
+ # Kullanıcıdan veriler almak için input alanları
22
+ st.header("Please fill in the following information:")
23
+
24
+ # Numeric sütunlar
25
+ Age = st.number_input("Age", min_value=0, max_value=100, value=25, step=1)
26
+ Height = st.number_input("Height (cm)", min_value=100, max_value=250, value=170, step=1)
27
+ Weight = st.number_input("Weight (kg)", min_value=30, max_value=200, value=70, step=1)
28
+ FCVC = st.number_input("Frequency of consumption of vegetables", min_value=0.0, max_value=3.0, value=1.0, step=0.5)
29
+ NCP = st.number_input("Number of main meals", min_value=0, max_value=6, value=3, step=1)
30
+ CH2O = st.number_input("Daily water consumption", min_value=0.0, max_value=3.0, value=1.0, step=0.5)
31
+ FAF = st.number_input("Physical activity frequency", min_value=0.0, max_value=3.0, value=1.0, step=0.5)
32
+ TUE = st.number_input("Time spent sitting (hours)", min_value=0.0, max_value=16.0, value=8.0, step=1.0)
33
+
34
+ # Categoric sütunlar
35
+ Gender = st.selectbox("Gender", ("Female","Male"))
36
+ family_history_with_overweight = st.selectbox("Family history with overweight", ("yes", "no"))
37
+ FAVC = st.selectbox("Frequent consumption of high caloric food", ("yes", "no"))
38
+ CAEC = st.selectbox("Regular consumption of vegetables", ("Sometimes", "Frequently","Always","no"))
39
+ SMOKE = st.selectbox("Do you smoke?", ("no", "yes"))
40
+ SCC = st.selectbox("Time spent sitting (hours)", ("yes", "no"))
41
+ CALC = st.selectbox("Alcohol consumption", ("Sometimes", "no", "Frequently"))
42
+ MTRANS = st.selectbox("Transportation used", ("Automobile", "Walking ", "Motorbike", "Bike"))
43
+
44
+ # Verileri işleme ve model ile tahmin yapma
45
+ if st.button("Calculate Obesity Risk"):
46
+ # Kullanıcı verilerini modele uygun formata getirme
47
+ # Kategorik verileri encode etme
48
+ input_data = np.array([Gender, Age, Height, Weight, family_history_with_overweight, FAVC, FCVC, NCP, CAEC, SMOKE, CH2O, SCC, FAF, TUE, CALC, MTRANS]).reshape(1, -1)
49
+
50
+
51
+ input_data=pd.DataFrame()
52
+ print(input_data)
53
+ # Veri ön işleme adımlarını uygulama
54
+ input_data_processed = preprocessor.fit_transform(input_data)
55
+
56
+ # Risk tahmini
57
+ risk_prediction = model.predict(input_data_processed)
58
+ risk_category = "Low" if risk_prediction == 0 else "High"
59
+
60
+ # Tahmin sonucunu gösterme
61
+ st.subheader("Prediction Result:")
62
+ st.write(f"Your obesity risk is: {risk_category}. Let's see, diet or exercise, or maybe pizza? Your call!")
63
+
64
+ # İronik açıklamalar
65
+ if risk_category == "Low":
66
+ st.write("You're in luck! Your obesity risk is low. But still, keep eating healthy and stay active. After all, laziness adds weight!")
67
+ else:
68
+ st.write("Oh no, looks like your obesity risk is high. Time to give up pizzas and say hello to vegetables. Remember, diets always start on Mondays!")
obesity.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5df0627796665233db160b521549f69282ba7788f6b1f0efee54d02dc660ee56
3
+ size 915609
preprocessor.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a432fef233e52864cd06ca7b7be1357c2d8a533170b8f6a68090fb9a6180e5c3
3
+ size 3215
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ scikit-learn
3
+ numpy
4
+ pandas