Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .gitattributes +1 -0
- app.py +124 -0
- hotel_model.keras +3 -0
- scaler.pkl +3 -0
- test_data.csv +31 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
hotel_model.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
import pickle
|
| 6 |
+
from tensorflow.keras.models import load_model
|
| 7 |
+
|
| 8 |
+
# Sayfa Yapılandırması
|
| 9 |
+
st.set_page_config(page_title="Hotel AI Decision Support", layout="wide")
|
| 10 |
+
|
| 11 |
+
@st.cache_resource
|
| 12 |
+
def load_assets():
|
| 13 |
+
model = load_model("hotel_model.keras")
|
| 14 |
+
with open("scaler.pkl", "rb") as f:
|
| 15 |
+
sc = pickle.load(f)
|
| 16 |
+
return model, sc
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
model, sc = load_assets()
|
| 20 |
+
except Exception as e:
|
| 21 |
+
st.error(f"Error: Assets not found! / Hata: Dosyalar bulunamadı! {e}")
|
| 22 |
+
st.stop()
|
| 23 |
+
|
| 24 |
+
# ==========================================
|
| 25 |
+
# SIDEBAR / SOL PANEL (REHBER GERİ GELDİ)
|
| 26 |
+
# ==========================================
|
| 27 |
+
with st.sidebar:
|
| 28 |
+
st.markdown("### 📖 Guide & Info / Rehber")
|
| 29 |
+
st.info("""
|
| 30 |
+
**How to Upload? / Nasıl Yüklenmeli?**
|
| 31 |
+
CSV Format:
|
| 32 |
+
| bookings |
|
| 33 |
+
| :--- |
|
| 34 |
+
| 150 |
|
| 35 |
+
| 210 |
|
| 36 |
+
""")
|
| 37 |
+
st.markdown("---")
|
| 38 |
+
st.markdown("### ❓ What is 'Bookings'? / 'Bookings' Nedir?")
|
| 39 |
+
st.write("""
|
| 40 |
+
**EN:** Total daily reservations. If 2023-05-10 is 150, it means 150 rooms were booked.
|
| 41 |
+
|
| 42 |
+
**TR:** Günlük toplam rezervasyon. Eğer 2023-05-10 değeri 150 ise, o gün 150 oda satılmış demektir.
|
| 43 |
+
""")
|
| 44 |
+
st.markdown("---")
|
| 45 |
+
st.markdown("### 📊 Thresholds / Yoğunluk")
|
| 46 |
+
st.warning("High (Yoğun): > Avg + 20%")
|
| 47 |
+
st.success("Stable (Stabil): Normal range")
|
| 48 |
+
st.markdown("---")
|
| 49 |
+
file = st.sidebar.file_uploader("Upload CSV / CSV Yükle", type=["csv"])
|
| 50 |
+
|
| 51 |
+
# ==========================================
|
| 52 |
+
# MAIN CONTENT / ANA SAYFA
|
| 53 |
+
# ==========================================
|
| 54 |
+
st.markdown("<h1 style='text-align: center;'>🏨 Hotel Demand Forecasting / Otel Talep Tahmini</h1>", unsafe_allow_html=True)
|
| 55 |
+
|
| 56 |
+
if file is not None:
|
| 57 |
+
df = pd.read_csv(file)
|
| 58 |
+
|
| 59 |
+
# Hesaplamalar
|
| 60 |
+
raw_data = df[["bookings"]].values
|
| 61 |
+
data_scaled = sc.transform(raw_data)
|
| 62 |
+
predictions_scaled = model.predict(data_scaled)
|
| 63 |
+
predictions = sc.inverse_transform(predictions_scaled).flatten().astype(int)
|
| 64 |
+
|
| 65 |
+
avg_val = int(predictions.mean())
|
| 66 |
+
busy_limit = int(avg_val * 1.2)
|
| 67 |
+
current_max = int(predictions.max())
|
| 68 |
+
|
| 69 |
+
# 1. METRİKLER
|
| 70 |
+
st.markdown("---")
|
| 71 |
+
c1, c2, c3 = st.columns(3)
|
| 72 |
+
with c1:
|
| 73 |
+
st.markdown(f"<div style='text-align: center;'><strong>Avg Forecast / Ort. Tahmin</strong><br><span style='font-size: 45px; color: #2980b9;'>{avg_val}</span></div>", unsafe_allow_html=True)
|
| 74 |
+
with c2:
|
| 75 |
+
st.markdown(f"<div style='text-align: center;'><strong>Busy Threshold / Yoğunluk Sınırı</strong><br><span style='font-size: 45px; color: #e74c3c;'>{busy_limit}</span></div>", unsafe_allow_html=True)
|
| 76 |
+
with c3:
|
| 77 |
+
status_color = "#e67e22" if current_max >= busy_limit else "#27ae60"
|
| 78 |
+
status_text = "HIGH / YOĞUN" if current_max >= busy_limit else "STABLE / STABİL"
|
| 79 |
+
st.markdown(f"<div style='text-align: center;'><strong>Status / Durum</strong><br><span style='font-size: 40px; color: {status_color}; font-weight: bold;'>{status_text}</span></div>", unsafe_allow_html=True)
|
| 80 |
+
|
| 81 |
+
# 2. YÖNETİM TAVSİYESİ
|
| 82 |
+
st.markdown("---")
|
| 83 |
+
st.markdown("<h3 style='text-align: center;'>👔 Management Advice / Yönetim Tavsiyesi</h3>", unsafe_allow_html=True)
|
| 84 |
+
advice_col_en, advice_col_tr = st.columns(2)
|
| 85 |
+
with advice_col_en:
|
| 86 |
+
if current_max >= busy_limit: st.warning("**High Demand:** Peak days detected. Increase staff.")
|
| 87 |
+
else: st.success("**Stable Demand:** Demand is normal. Focus on maintenance.")
|
| 88 |
+
with advice_col_tr:
|
| 89 |
+
if current_max >= busy_limit: st.warning("**Yoğun Talep:** Zirve günler tespit edildi. Personel artırın.")
|
| 90 |
+
else: st.success("**Stabil Talep:** Talep normal. Bakım işlerine odaklanılabilir.")
|
| 91 |
+
|
| 92 |
+
# 3. SONUÇ TABLOSU (YUKARIYA TAŞINDI)
|
| 93 |
+
st.markdown("---")
|
| 94 |
+
st.subheader("📋 Results Table / Sonuç Tablosu")
|
| 95 |
+
result_df = pd.DataFrame({
|
| 96 |
+
"Actual / Gerçek": raw_data.flatten(),
|
| 97 |
+
"Predicted / Tahmin": predictions
|
| 98 |
+
})
|
| 99 |
+
st.dataframe(result_df, use_container_width=True, height=250)
|
| 100 |
+
|
| 101 |
+
st.download_button(
|
| 102 |
+
label="📥 Download Results / Sonuçları İndir",
|
| 103 |
+
data=result_df.to_csv(index=False).encode('utf-8'),
|
| 104 |
+
file_name="hotel_forecast_results.csv",
|
| 105 |
+
mime="text/csv"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
# 4. GRAFİK
|
| 109 |
+
st.markdown("---")
|
| 110 |
+
st.subheader("📈 Prediction Graph / Tahmin Grafiği")
|
| 111 |
+
fig, ax = plt.subplots(figsize=(10, 3.5))
|
| 112 |
+
ax.plot(raw_data, label="Actual / Gerçek", color="#bdc3c7", alpha=0.6, linestyle='--')
|
| 113 |
+
ax.plot(predictions, label="AI Forecast / YZ Tahmini", color="#2980b9", linewidth=2)
|
| 114 |
+
ax.axhline(y=busy_limit, color='#e74c3c', linestyle=':', label="Limit")
|
| 115 |
+
ax.legend(prop={'size': 8})
|
| 116 |
+
st.pyplot(fig)
|
| 117 |
+
|
| 118 |
+
# 5. VERİ ÖN İZLEME (EN ALTTA)
|
| 119 |
+
st.markdown("---")
|
| 120 |
+
st.subheader("📊 Data Preview / Veri Ön İzleme (Raw Data)")
|
| 121 |
+
st.dataframe(df, use_container_width=True, height=150)
|
| 122 |
+
|
| 123 |
+
else:
|
| 124 |
+
st.warning("👈 Please upload a CSV file from the left panel. / Lütfen sol panelden bir CSV dosyası yükleyin.")
|
hotel_model.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:56df47a06afe17a3240f4822dd5956c4081017bbfb51b8e8226f833dda3be532
|
| 3 |
+
size 229885
|
scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:23349bc970be5cea6e46fbc6c31d7e725addfa048bc5266b131efefbf90cd9a8
|
| 3 |
+
size 521
|
test_data.csv
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bookings
|
| 2 |
+
247
|
| 3 |
+
101
|
| 4 |
+
180
|
| 5 |
+
174
|
| 6 |
+
133
|
| 7 |
+
219
|
| 8 |
+
264
|
| 9 |
+
232
|
| 10 |
+
272
|
| 11 |
+
238
|
| 12 |
+
251
|
| 13 |
+
169
|
| 14 |
+
115
|
| 15 |
+
259
|
| 16 |
+
192
|
| 17 |
+
255
|
| 18 |
+
236
|
| 19 |
+
226
|
| 20 |
+
152
|
| 21 |
+
184
|
| 22 |
+
130
|
| 23 |
+
204
|
| 24 |
+
224
|
| 25 |
+
255
|
| 26 |
+
166
|
| 27 |
+
193
|
| 28 |
+
254
|
| 29 |
+
267
|
| 30 |
+
277
|
| 31 |
+
260
|