ESMATUGBA commited on
Commit
d39e80f
·
verified ·
1 Parent(s): 6c07b9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -33
app.py CHANGED
@@ -6,7 +6,7 @@ import pickle
6
  import os
7
  import warnings
8
 
9
- # Gereksiz uyarıları ve log kalabalığını gizle
10
  warnings.filterwarnings('ignore')
11
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
12
 
@@ -36,37 +36,51 @@ except Exception as e:
36
  st.stop()
37
 
38
  # ==========================================
39
- # SIDEBAR / SOL PANEL
40
  # ==========================================
41
  with st.sidebar:
42
  st.markdown("<h2 style='color: #2980b9;'>📖 User Guide / Rehber</h2>", unsafe_allow_html=True)
43
 
 
 
44
  st.info("""
45
- **How to Upload? / Nasıl Yüklenmeli?**
46
- CSV Format:
47
  | bookings |
48
  | :--- |
49
  | 120 |
50
  | 155 |
 
 
 
51
  """)
52
 
53
  st.markdown("---")
54
 
 
55
  st.markdown("### ❓ What is 'Bookings'? / 'Bookings' Nedir?")
56
- st.write("""
57
- **EN:** Total daily reservations. (Example: 150 = 150 rooms sold)
58
- **TR:** Günlük toplam rezervasyon. (Örnek: 150 = 150 oda satıldı)
 
 
 
 
 
59
  """)
60
 
61
  st.markdown("---")
62
 
63
- st.markdown("### 📊 Thresholds / Yoğunluk")
64
- st.warning("**High Demand (Yoğun):**\n> Average + 20%")
65
- st.success("**Stable (Stabil):**\nNormal range")
 
 
66
 
67
  st.markdown("---")
68
 
69
- file = st.file_uploader("Upload CSV / CSV Yükle", type=["csv"])
 
 
70
 
71
  # ==========================================
72
  # MAIN CONTENT / ANA SAYFA
@@ -76,10 +90,10 @@ st.markdown("<h1 style='text-align: center;'>🏨 Hotel Demand Forecasting / Ote
76
  if file is not None:
77
  df = pd.read_csv(file)
78
 
79
- # AI Tahmin İşlemleri
80
  raw_data = df[["bookings"]].values
81
  data_scaled = sc.transform(raw_data)
82
- predictions_scaled = model.predict(data_scaled, verbose=0) # verbose=0 log kirliliğini önler
83
  predictions = sc.inverse_transform(predictions_scaled).flatten().astype(int)
84
 
85
  avg_val = int(predictions.mean())
@@ -101,28 +115,21 @@ if file is not None:
101
  # 2. YÖNETİM TAVSİYESİ
102
  st.markdown("---")
103
  st.markdown("<h3 style='text-align: center;'>👔 Management Advice / Yönetim Tavsiyesi</h3>", unsafe_allow_html=True)
104
- adv_en, adv_tr = st.columns(2)
105
- with adv_en:
106
- if current_max >= busy_limit:
107
- st.warning("**High Demand Advice:** Peak days detected. Increase staff.")
108
- else:
109
- st.success("**Stable Demand Advice:** Demand is normal. Focus on maintenance.")
110
- with adv_tr:
111
- if current_max >= busy_limit:
112
- st.warning("**Yoğun Talep Tavsiyesi:** Zirve günler tespit edildi. Personel artırın.")
113
- else:
114
- st.success("**Stabil Talep Tavsiyesi:** Talep normal. Bakım işlerine odaklanılabilir.")
115
-
116
- # 3. SONUÇ TABLOSU (width='stretch' ile güncellendi)
117
  st.markdown("---")
118
  st.subheader("📋 Results Table / Sonuç Tablosu")
119
- result_df = pd.DataFrame({
120
- "Actual / Gerçek": raw_data.flatten(),
121
- "Predicted / Tahmin": predictions
122
- })
123
- st.dataframe(result_df, width=None, height=250) # width=None otomatik stretch yapar
124
 
125
- st.download_button("📥 Download Results", result_df.to_csv(index=False).encode('utf-8'), "hotel_results.csv", "text/csv")
126
 
127
  # 4. GRAFİK
128
  st.markdown("---")
@@ -137,7 +144,7 @@ if file is not None:
137
  # 5. VERİ ÖN İZLEME
138
  st.markdown("---")
139
  st.subheader("📊 Data Preview / Veri Ön İzleme")
140
- st.dataframe(df, width=None, height=150)
141
 
142
  else:
143
  st.warning("👈 Please upload a CSV file from the left panel. / Lütfen sol panelden bir CSV dosyası yükleyin.")
 
6
  import os
7
  import warnings
8
 
9
+ # Gereksiz logları ve versiyon uyarılarını kapat
10
  warnings.filterwarnings('ignore')
11
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
12
 
 
36
  st.stop()
37
 
38
  # ==========================================
39
+ # SIDEBAR / SOL PANEL (TÜM BİLGİLER GERİ GELDİ)
40
  # ==========================================
41
  with st.sidebar:
42
  st.markdown("<h2 style='color: #2980b9;'>📖 User Guide / Rehber</h2>", unsafe_allow_html=True)
43
 
44
+ # 1. NASIL YÜKLENMELİ?
45
+ st.markdown("### 📥 How to Upload? / Nasıl Yüklenmeli?")
46
  st.info("""
47
+ **CSV Format Example:**
 
48
  | bookings |
49
  | :--- |
50
  | 120 |
51
  | 155 |
52
+
53
+ *Ensure the column name is 'bookings'.*
54
+ *Sütun adının 'bookings' olduğundan emin olun.*
55
  """)
56
 
57
  st.markdown("---")
58
 
59
+ # 2. BOOKING NEDİR?
60
  st.markdown("### ❓ What is 'Bookings'? / 'Bookings' Nedir?")
61
+ st.markdown("""
62
+ **EN:** It represents the total number of reservations made on that day.
63
+
64
+ **TR:** O gün yapılan toplam rezervasyon sayısıdır.
65
+
66
+ **Example / Örnek:**
67
+ If value is **150**, it means 150 rooms were booked/sold that day for the hotel.
68
+ Eğer değer **150** ise, bu o gün o otel için 150 tane oda ayrıldığı anlamına gelir.
69
  """)
70
 
71
  st.markdown("---")
72
 
73
+ # 3. YOĞUNLUK VE STABİLİTE MANTIĞI
74
+ st.markdown("### 📊 Thresholds / Yoğunluk & Stabilite")
75
+ st.write("**How does AI decide? / YZ nasıl karar verir?**")
76
+ st.warning("**High Demand (Yoğun):** Forecast is 20% above the average. / Tahmin ortalamanın %20 üzerindeyse.")
77
+ st.success("**Stable (Stabil):** Forecast is within normal limits. / Tahmin normal sınırlar içerisindeyse.")
78
 
79
  st.markdown("---")
80
 
81
+ # 4. DOSYA YÜKLEME
82
+ st.markdown("### 🚀 Start / Başlat")
83
+ file = st.file_uploader("Choose CSV / CSV Seç", type=["csv"])
84
 
85
  # ==========================================
86
  # MAIN CONTENT / ANA SAYFA
 
90
  if file is not None:
91
  df = pd.read_csv(file)
92
 
93
+ # AI Analizi
94
  raw_data = df[["bookings"]].values
95
  data_scaled = sc.transform(raw_data)
96
+ predictions_scaled = model.predict(data_scaled, verbose=0)
97
  predictions = sc.inverse_transform(predictions_scaled).flatten().astype(int)
98
 
99
  avg_val = int(predictions.mean())
 
115
  # 2. YÖNETİM TAVSİYESİ
116
  st.markdown("---")
117
  st.markdown("<h3 style='text-align: center;'>👔 Management Advice / Yönetim Tavsiyesi</h3>", unsafe_allow_html=True)
118
+ ce, ct = st.columns(2)
119
+ with ce:
120
+ if current_max >= busy_limit: st.warning("**High Demand Advice:** Peak days detected. Increase staff.")
121
+ else: st.success("**Stable Demand Advice:** Demand is normal. Focus on maintenance.")
122
+ with ct:
123
+ if current_max >= busy_limit: st.warning("**Yoğun Talep Tavsiyesi:** Zirve günler tespit edildi. Personel artırın.")
124
+ else: st.success("**Stabil Talep Tavsiyesi:** Talep normal. Bakım işlerine odaklanılabilir.")
125
+
126
+ # 3. SONUÇ TABLOSU (HATA DÜZELTİLDİ: width='stretch')
 
 
 
 
127
  st.markdown("---")
128
  st.subheader("📋 Results Table / Sonuç Tablosu")
129
+ res_df = pd.DataFrame({"Actual / Gerçek": raw_data.flatten(), "Predicted / Tahmin": predictions})
130
+ st.dataframe(res_df, width='stretch', height=250)
 
 
 
131
 
132
+ st.download_button("📥 Download Results", res_df.to_csv(index=False).encode('utf-8'), "hotel_results.csv", "text/csv")
133
 
134
  # 4. GRAFİK
135
  st.markdown("---")
 
144
  # 5. VERİ ÖN İZLEME
145
  st.markdown("---")
146
  st.subheader("📊 Data Preview / Veri Ön İzleme")
147
+ st.dataframe(df, width='stretch', height=150)
148
 
149
  else:
150
  st.warning("👈 Please upload a CSV file from the left panel. / Lütfen sol panelden bir CSV dosyası yükleyin.")