Spaces:
Sleeping
Sleeping
File size: 3,069 Bytes
cced09c | 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 | import streamlit as st
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pickle
from keras.models import load_model
# 1. Sayfa Ayarları / Page Settings
st.set_page_config(page_title="Weather Forecast", layout="wide")
@st.cache_resource
def modeli_getir():
# Model ismin .keras olduğu için böyle güncelledim
model = load_model("lstm_traffic_model.keras")
return model
@st.cache_resource
def scaler_getir():
with open("scaler.pkl", "rb") as f:
return pickle.load(f)
model = modeli_getir()
olcekleyici = scaler_getir()
# --- SIDEBAR / YAN PANEL ---
st.sidebar.header("📁 CSV Format Guide / Rehber")
st.sidebar.info("""
**English:** Your file must contain the following columns in order:
`date`, `meantemp`, `humidity`, `wind_speed`, `meanpressure`.
**Türkçe:** Dosyanız şu sütunları sırasıyla içermelidir:
`date`, `meantemp`, `humidity`, `wind_speed`, `meanpressure`.
""")
# Senin gerçek verinden bir kesit örnek olarak
ornek_data = pd.DataFrame({
'date': ['2015-08-21', '2015-08-22'],
'meantemp': [29.375, 30.25],
'humidity': [72, 65.37],
'wind_speed': [8.57, 5.8],
'meanpressure': [1002, 1000.8]
})
st.sidebar.write("Example Format / Örnek Format:", ornek_data)
# --- MAIN PAGE / ANA SAYFA ---
st.title("🌡️ Weather Forecasting System / Hava Durumu Tahmin Sistemi")
st.markdown("### LSTM Network Analysis / LSTM Ağ Analizi")
# Dosya Yükleme
dosya = st.file_uploader("Upload your CSV file / CSV Dosyanızı Yükleyin", type=["csv"])
if dosya is not None:
df = pd.read_csv(dosya)
col1, col2 = st.columns(2)
with col1:
st.subheader("📊 Data Preview / Veri Önizleme")
st.write(df.head())
try:
# ÖNEMLİ: Senin verinde 'meantemp' 2. kolonda (index 1)
# Sadece bu kolonu tahmin için seçiyoruz
veriler = df.iloc[:, 1:2].values
# Scale işlemi
olcekli_veriler = olcekleyici.transform(veriler)
# Tahmin (LSTM tahmini)
tahminler_scaled = model.predict(olcekli_veriler)
tahminler = olcekleyici.inverse_transform(tahminler_scaled)
with col2:
st.subheader("📈 Prediction Result / Tahmin Sonucu")
fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(veriler, label="Actual / Gerçek", color="#e74c3c", linewidth=2)
ax.plot(tahminler, label="Predicted / Tahmin", color="#3498db", linestyle="--", linewidth=2)
ax.set_title("Temperature Forecast")
ax.set_ylabel("Celsius (°C)")
ax.legend()
st.pyplot(fig)
# Kutlama Balonları
st.balloons()
st.success("✅ Process Completed! / İşlem Başarıyla Tamamlandı!")
except Exception as e:
st.error(f"Error / Hata: {e}. Please check your column order.")
else:
st.warning("👈 Please upload a CSV file to start / Başlamak için lütfen bir CSV dosyası yükleyin.") |