File size: 5,408 Bytes
6a0cd44
 
 
a10e91e
6a0cd44
a10e91e
 
 
 
93b0ecf
 
a10e91e
094b146
6af38a8
a10e91e
 
 
 
 
 
d484c14
6af38a8
a10e91e
6af38a8
a10e91e
7a16aef
 
d484c14
a10e91e
7a16aef
93b0ecf
7a16aef
93b0ecf
 
 
 
 
 
a10e91e
 
93b0ecf
 
 
a10e91e
 
93b0ecf
7a16aef
a10e91e
6af38a8
7a16aef
a10e91e
 
7a16aef
93b0ecf
a014156
93b0ecf
6af38a8
a10e91e
 
 
 
 
 
 
 
 
6af38a8
a014156
93b0ecf
6af38a8
a10e91e
 
 
 
 
 
 
 
 
6af38a8
 
 
 
a10e91e
6af38a8
a10e91e
 
 
 
 
 
 
 
 
7a16aef
f102b68
 
a10e91e
 
6a0cd44
094b146
8ef4521
094b146
a10e91e
d228af0
 
7a16aef
094b146
a10e91e
 
 
 
094b146
a10e91e
 
 
094b146
 
a10e91e
 
 
 
094b146
6af38a8
a10e91e
094b146
a10e91e
094b146
a10e91e
094b146
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import streamlit as st
import pandas as pd
import numpy as np
import os

# --- TİTREME KİLİDİ (Watcher kapatıldı) ---
os.environ["STREAMLIT_SERVER_FILE_WATCHER_TYPE"] = "none"

# --- SAYFA AYARLARI ---
st.set_page_config(page_title="Fast Food Nutrition Guide", layout="wide")

# --- DATA LOAD (CACHE) ---
@st.cache_data
def load_data(path):
    try:
        df = pd.read_csv(path)
        df = df.replace([np.inf, -np.inf], np.nan).dropna()
        return df
    except:
        return None

path = "Nutrition_Value_Dataset.csv"
df = load_data(path)

if df is None:
    st.error("CSV file not found! / Veri seti dosyası bulunamadı!")
    st.stop()

# --- SIDEBAR (SAĞLIK REHBERİ - EKSİKSİZ) ---
st.sidebar.title("🏥 Health & Calorie Guide / Sağlık ve Kalori Rehberi")

st.sidebar.subheader("⚖️ Daily Calorie Needs / Günlük Kalori İhtiyacı")
st.sidebar.write("""
- **Women / Kadınlar:** 2,000kcal 
- **Men / Erkekler:** 2,500 kcal
""")

st.sidebar.warning("""
⚠️ **Health Advice / Sağlık Öğüdü:** Fast food meals are high in sodium and low in nutrients.  
*Fast food öğünleri sodyum bakımından yüksek, besin değeri bakımından düşüktür.*
""")

st.sidebar.info("""
💡 **Quick Tip / Pratik Bilgi:** Choosing water over soda can reduce your meal's sugar content by 40-60g.  
*Asitli içecek yerine su seçmek, öğününüzdeki şeker miktarını 40-60 gr azaltabilir.*
""")

# --- ANA SAYFA BAŞLIK ---
st.title("🍔 Global Fast Food Nutrition Analysis / Küresel Fast Food Besin Analizi")

# --- TÜKETİCİYE KRİTİK NOT (YAN YANA) ---
st.error("### 📢 Important Notice for Consumers / Tüketiciler İçin Önemli Not")

col_note_tr, col_note_en = st.columns(2)

with col_note_tr:
    st.markdown("""
    **Aşağıdaki verilere istinaden, bu şirketlerden yemek tüketilmemesi sağlığınız için şu nedenlerle yararlı olacaktır:**
    
    1. **Kalp Sağlığı:** Yüksek trans yağ ve sodyum içeriği damar sertliği ve tansiyona neden olur.
    2. **Kan Şekeri Dengesi:** Aşırı şeker ve işlenmiş karbonhidratlar ani insülin direnci ve diyabet riskini tetikler.
    3. **Besin Değeri Eksikliği:** Bu ürünler "boş kalori" kaynağıdır; vitamin, mineral ve lif açısından son derece fakirdir.
    4. **Obezite Riski:** **Pizza Hut, Burger King, KFC, McDonald’s ve Starbucks** şirketlerinden yüksek kalori yoğunluğu olacağından kısa sürede kontrolsüz kilo alımına yol açar.
    
    * **🥤 Su İçin:** Asitli içecekler yerine su tüketmek sağlığınız için kritiktir.
    * **🥩 Protein Vurgusu:** Kas sağlığı ve metabolizma için **protein ağırlıklı** beslenmeye özen gösterilmelidir.
    """)

with col_note_en:
    st.markdown("""
    **Based on the data below, avoiding these companies' meals will benefit your health for the following reasons:**
    
    1. **Heart Health:** High trans fat and sodium content cause arteriosclerosis and high blood pressure.
    2. **Blood Sugar Balance:** Excessive sugar and processed carbs trigger insulin resistance and diabetes risk.
    3. **Lack of Nutrients:** These products are sources of "empty calories"; they are extremely poor in vitamins and minerals.
    4. **Obesity Risk:** High calorie density in foods from companies like **Pizza Hut, Burger King, KFC, McDonald’s, and Starbucks** can lead to rapid, uncontrolled weight gain.
    
    * **🥤 Drink Water:** Choosing water instead of sugary drinks is critical for your health.
    * **🥩 Focus on Protein:** Prioritize **protein-rich** nutrition for muscle health and metabolism.
    """)

st.write("---")

# --- ÖDEV METNİ (GÖRSEL KUTU) ---
st.markdown("""
<div style="text-align: center; border: 1px solid #ddd; padding: 15px; border-radius: 10px; background-color: #f9f9f9;">
    <h3 style="color: #1E1E1E; font-weight: bold; margin: 0;">
        🔍 Bu çalışma, fast food ürünlerinin kalori ve şeker içeriklerini görselleştirerek genel bir sağlık tablosu sunmaktadır.
    </h3>
    <h4 style="color: #555555; margin: 10px 0 0 0;">
        This study provides a general health overview by visualizing the calorie and sugar content of fast food products.
    </h4>
</div>
""", unsafe_allow_html=True)

st.write("---")

# --- GRAFİKLER (SABİT DÜZEN) ---
st.subheader("📊 General Visual Analysis / Genel Görsel Analiz")

c1, c2 = st.columns(2)

with c1:
    st.write("🍭 **Average Sugar by Company / Şirketlere Göre Ort. Şeker**")
    sugar_means = df.groupby("Company")["Sugar (g)"].mean().sort_values()
    st.bar_chart(sugar_means)

with c2:
    st.write("🔥 **Overall Calorie Distribution / Genel Kalori Dağılımı**")
    # Histogram verisini hazırlayıp titremeyen bar_chart ile basıyoruz
    counts, bin_edges = np.histogram(df["Energy (kCal)"], bins=20)
    st.bar_chart(counts)

# --- VERİ TABLOSU (TITREME YAPMAYAN GENİŞLİK AYARI) ---
st.write("---")
st.subheader("📋 High-Calorie Products List / Yüksek Kalorili Ürün Listesi")
top_20 = df.sort_values(by="Energy (kCal)", ascending=False).head(20)

st.dataframe(
    top_20[["Company", "Product", "Energy (kCal)", "Sugar (g)", "Protein (g)", "Total Fat (g)"]], 
    use_container_width=True
)

# --- DOWNLOAD ---
st.write("---")
st.download_button(
    "📥 Download Full Dataset / Tüm Veriyi İndir",
    df.to_csv(index=False),
    "fastfood_nutrition_final.csv",
    "text/csv"
)