This commit is contained in:
Azmikun1 2025-12-17 15:30:38 +07:00
parent 15eda61833
commit bb8fa42585
2 changed files with 332 additions and 158 deletions

483
app.py
View File

@ -1,3 +1,4 @@
import requests
import streamlit as st import streamlit as st
import joblib import joblib
import pandas as pd import pandas as pd
@ -11,262 +12,428 @@ import matplotlib.pyplot as plt
import matplotlib.dates as mdates import matplotlib.dates as mdates
from matplotlib import rcParams from matplotlib import rcParams
# Set font # Set font untuk mendukung karakter Indonesia
rcParams['font.family'] = 'DejaVu Sans' rcParams['font.family'] = 'DejaVu Sans'
# --- Konfigurasi Halaman --- # --- Konfigurasi Halaman ---
st.set_page_config(page_title="Prediksi Harga Ethereum (GRU)", page_icon="🪙") st.set_page_config(
page_title="Prediksi Harga Ethereum (GRU)",
page_icon="🪙"
)
# --- GLOBAL STYLES --- # --- GLOBAL STYLES (UI only) ---
st.markdown(""" st.markdown("""
<style> <style>
/* font & warna dasar */
html, body, [class*="css"] { font-family: "Inter", "DejaVu Sans", sans-serif; }
:root {
--card-bg: #ffffff;
--muted: #6b7280;
--ring: #e5e7eb;
}
/* gradient title */
.app-title { .app-title {
text-align:center; font-weight:800; font-size: 32px; text-align:center;
font-weight:800;
font-size: 32px;
background: linear-gradient(90deg, #6EE7F9 0%, #7C3AED 50%, #F59E0B 100%); background: linear-gradient(90deg, #6EE7F9 0%, #7C3AED 50%, #F59E0B 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent; -webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin: 0.25rem 0 0.5rem 0; margin: 0.25rem 0 0.5rem 0;
} }
.app-subtitle { text-align:center; color: #6b7280; margin-bottom: 1.25rem; }
.card { /* subtitle */
background: #ffffff; border: 1px solid #e5e7eb; border-radius: 16px; .app-subtitle {
padding: 1rem 1.25rem; box-shadow: 0 6px 20px rgba(0,0,0,0.05); margin-bottom: 1rem; text-align:center;
color: var(--muted);
margin-bottom: 1.25rem;
}
/* card container */
.card {
background: var(--card-bg);
border: 1px solid var(--ring);
border-radius: 16px;
padding: 1rem 1.25rem;
box-shadow: 0 6px 20px rgba(0,0,0,0.05);
margin-bottom: 1rem;
}
/* section heading */
.h-section {
font-weight:700;
font-size: 20px;
margin: 0 0 .5rem 0;
}
/* table tweaks */
.dataframe tbody tr:hover { background-color: #fafafa; }
/* footer */
.footer {
text-align:center;
color: var(--muted);
font-size: 13px;
margin-top: 2rem;
} }
.h-section { font-weight:700; font-size: 20px; margin: 0 0 .5rem 0; }
.footer { text-align:center; color: #6b7280; font-size: 13px; margin-top: 2rem; }
</style> </style>
""", unsafe_allow_html=True) """, unsafe_allow_html=True)
# --- TOMBOL RESET CACHE (PENTING!) ---
with st.sidebar:
st.header("⚙️ Kontrol Data")
if st.button("🔄 Paksa Update Data (Clear Cache)"):
st.cache_data.clear()
st.success("Cache dihapus! Silakan tekan 'R' untuk reload.")
st.stop() # Hentikan app sebentar biar user reload
# --- FUNGSI LOAD DATA (VERSI YFINANCE ONLY) --- # --- Fungsi-fungsi Bantuan ---
@st.cache_data(ttl="1h") @st.cache_data(ttl="1h")
def load_eth_data(): def load_eth_data():
"""
Fokus: Download via Library yfinance.
Fitur:
1. Mengatasi data bolong (Resample Daily).
2. Auto Adjust harga (OHLC bersih).
"""
ticker = "ETH-USD" ticker = "ETH-USD"
df = None
# Kita set start date agak jauh biar grafiknya bagus # 1. COBA ONLINE
start_date = "2024-01-01"
end_date = date.today() + timedelta(days=1)
st.toast("Sedang menghubungi server Yahoo Finance...", icon="")
try: try:
# DOWNLOAD ONLINE
df = yf.download( df = yf.download(
ticker, ticker,
start=start_date, start="2024-01-01",
end=end_date, end=date.today() + timedelta(days=1),
progress=False, progress=False,
auto_adjust=True, # Biar harga bersih auto_adjust=True,
multi_level_index=False multi_level_index=False
) )
if df is not None and not df.empty: if df is not None and not df.empty:
# 1. Bersihkan Index # Bersihkan Index & Kolom
df = df.reset_index() df = df.reset_index()
# 2. Rapikan Kolom (Cegah MultiIndex/Tuple)
new_cols = [] new_cols = []
for col in df.columns: for col in df.columns:
col_name = col[0] if isinstance(col, tuple) else str(col) col_name = col[0] if isinstance(col, tuple) else str(col)
new_cols.append(col_name) new_cols.append(col_name)
df.columns = new_cols df.columns = new_cols
# 3. Pastikan kolom Date ada # Pastikan kolom pertama adalah Date
if 'Date' not in df.columns: if 'Date' not in df.columns:
df = df.rename(columns={df.columns[0]: 'Date'}) df = df.rename(columns={df.columns[0]: 'Date'})
# 4. Hapus Timezone
df['Date'] = pd.to_datetime(df['Date']).dt.tz_localize(None)
# --- BAGIAN PENTING: TAMBAL DATA BOLONG (RESAMPLING) ---
# Ini mengatasi masalah "Loncat" dari tgl 15 ke 17.
# Kita paksa buat tanggal harian (Daily) lengkap.
df = df.sort_values('Date').set_index('Date')
# Buat range tanggal penuh dari awal sampai akhir data
full_idx = pd.date_range(start=df.index.min(), end=df.index.max(), freq='D')
# Reindex & Forward Fill (Isi kekosongan dengan data hari sebelumnya)
df = df.reindex(full_idx).ffill().reset_index()
df = df.rename(columns={'index': 'Date'})
# -------------------------------------------------------
# 5. Simpan Backup Otomatis # Hapus Timezone
df['Date'] = pd.to_datetime(df['Date']).dt.tz_localize(None)
# Simpan Backup (Timpa file lama agar fresh)
try: try:
df.to_csv("eth_backup.csv", index=False) df.to_csv("eth_backup.csv", index=False)
except: except:
pass pass
return df, "online" return df, "online"
except Exception as e:
print(f"Error yfinance: {e}")
# FALLBACK: JIKA DOWNLOAD GAGAL, BACA BACKUP LAMA except Exception as e:
print(f"Gagal Online: {e}")
# 2. COBA BACKUP (JIKA ONLINE GAGAL)
try: try:
df_backup = pd.read_csv("eth_backup.csv") df_backup = pd.read_csv("eth_backup.csv")
if "Unnamed: 0" in df_backup.columns: df_backup = df_backup.drop(columns=["Unnamed: 0"])
if "Date" not in df_backup.columns: df_backup = df_backup.rename(columns={df_backup.columns[0]: "Date"})
df_backup["Date"] = pd.to_datetime(df_backup["Date"]).dt.tz_localize(None)
# Bersihkan kolom sampah jika ada
if "Unnamed: 0" in df_backup.columns:
df_backup = df_backup.drop(columns=["Unnamed: 0"])
# Pastikan kolom Date dikenali
if "Date" in df_backup.columns:
df_backup["Date"] = pd.to_datetime(df_backup["Date"])
elif df_backup.columns[0].lower() == "date":
df_backup = df_backup.rename(columns={df_backup.columns[0]: "Date"})
df_backup["Date"] = pd.to_datetime(df_backup["Date"])
return df_backup, "backup" return df_backup, "backup"
except:
except FileNotFoundError:
# 3. GAGAL TOTAL
return None, "error" return None, "error"
# --- Fungsi Helper Lainnya (Model & Scaler) ---
def validate_scaler(scaler): def validate_scaler(scaler):
issues, warnings = [], [] """Validasi scaler agar konsisten dengan training."""
if not isinstance(scaler, MinMaxScaler): warnings.append(f"Scaler bukan MinMaxScaler.") issues = []
return (len(issues)==0), issues, warnings warnings = []
if not isinstance(scaler, MinMaxScaler):
warnings.append(f"Scaler bukan MinMaxScaler (terdeteksi: {type(scaler).__name__}). Pastikan ini scaler training.")
required_attrs = ["n_features_in_", "data_min_", "data_max_", "scale_", "min_"]
for a in required_attrs:
if not hasattr(scaler, a):
issues.append(f"Scaler belum ter-fit atau tidak valid (atribut '{a}' tidak ada).")
if hasattr(scaler, "n_features_in_"):
if int(scaler.n_features_in_) != 1:
issues.append(f"Scaler mengharapkan {scaler.n_features_in_} fitur, tapi aplikasi hanya pakai 1 fitur ('Close').")
ok = (len(issues) == 0)
return ok, issues, warnings
def validate_model_input(model): def validate_model_input(model):
"""Pastikan input model bentuknya (None, time_step, 1)."""
issues = [] issues = []
try: try:
shape = model.input_shape shape = model.input_shape # biasanya (None, time_step, 1)
if shape[2] != 1: issues.append(f"Fitur model = {shape[2]}, input = 1.") if not (isinstance(shape, (list, tuple)) and len(shape) == 3):
except: pass issues.append(f"input_shape tidak sesuai harapan: {shape} (harus 3 dimensi).")
return (len(issues)==0), issues else:
if shape[2] != 1:
issues.append(f"Jumlah fitur input model = {shape[2]}, tapi aplikasi membentuk fitur=1.")
if shape[1] is None or int(shape[1]) <= 1:
issues.append(f"time_step tidak valid: {shape[1]}.")
except Exception as e:
issues.append(f"Gagal membaca input_shape model: {e}")
ok = (len(issues) == 0)
return ok, issues
@st.cache_resource @st.cache_resource
def load_gru_assets(): def load_gru_assets():
"""Load model & scaler hasil training (wajib pakai scaler yang sama)."""
model_path = Path("gru_model.h5") model_path = Path("gru_model.h5")
scaler_path = Path("scaler_gru.pkl") scaler_path = Path("scaler_gru.pkl")
if not model_path.exists() or not scaler_path.exists(): return None, None
if not model_path.exists() or not scaler_path.exists():
st.warning(
f"File tidak ditemukan.\n"
f"Model: {model_path.resolve().name} ada? {model_path.exists()}\n"
f"Scaler: {scaler_path.resolve().name} ada? {scaler_path.exists()}"
)
return None, None
try: try:
model = load_model(model_path, compile=False) model = load_model(model_path, compile=False)
scaler = joblib.load(scaler_path) scaler = joblib.load(scaler_path)
ok_scaler, scaler_issues, scaler_warnings = validate_scaler(scaler)
for w in scaler_warnings:
st.warning("⚠️ " + w)
if not ok_scaler:
st.error("❌ Scaler tidak kompatibel:\n- " + "\n- ".join(scaler_issues))
return None, None
ok_model, model_issues = validate_model_input(model)
if not ok_model:
st.error("❌ Model input tidak kompatibel:\n- " + "\n- ".join(model_issues))
return None, None
return model, scaler return model, scaler
except: return None, None
except Exception as e:
st.error(f"Gagal load aset: {e}")
return None, None
def predict_from_sequence_pure(model, initial_sequence_scaled, n_days): def predict_from_sequence_pure(model, initial_sequence_scaled, n_days):
seq = np.array(initial_sequence_scaled, dtype="float32").reshape(-1)
seq = np.array(initial_sequence_scaled, dtype="float32").reshape(-1) # (time_step,)
preds = [] preds = []
for _ in range(n_days): for _ in range(n_days):
x = seq.reshape(1, -1, 1) x = seq.reshape(1, -1, 1) # (1, time_step, 1)
y = float(model.predict(x, verbose=0)[0, 0]) y = float(model.predict(x, verbose=0)[0, 0]) # output model (scaled)
preds.append(y) preds.append(y)
seq = np.append(seq[1:], y) seq = np.append(seq[1:], y) # autoregressive (murni)
return np.array(preds, dtype="float32").reshape(-1, 1) return np.array(preds, dtype="float32").reshape(-1, 1)
def create_combined_chart(df, start_date, future_dates, future_predictions):
context_start = start_date - timedelta(days=60)
recent_df = df[(df["Date"] >= context_start) & (df["Date"] <= start_date)].copy()
recent_df["Trend"] = recent_df["Close"].rolling(window=7).mean()
fig, ax = plt.subplots(figsize=(14, 8))
ax.plot(recent_df["Date"], recent_df["Close"], color="gray", alpha=0.5, label="Harga Aktual")
ax.plot(recent_df["Date"], recent_df["Trend"], color="#1f77b4", linewidth=2, label="Tren Aktual")
ax.plot(future_dates, future_predictions.flatten(), color="#d62728", linewidth=2, marker="o", markersize=4, label="Prediksi GRU")
if not recent_df.empty:
ax.plot([recent_df["Date"].iloc[-1], future_dates[0]],
[recent_df["Trend"].dropna().iloc[-1], future_predictions.flatten()[0]],
color="#d62728", linestyle="--", alpha=0.7)
ax.set_title("Analisis Tren & Prediksi Ethereum") def create_combined_chart(df, start_date, future_dates, future_predictions):
"""Membuat grafik gabungan dengan gaya yang sama seperti referensi."""
context_start_date = start_date - timedelta(days=60)
recent_df = df[(df["Date"] >= context_start_date) & (df["Date"] <= start_date)].copy()
window_size = 7
recent_df["Trend_Aktual"] = recent_df["Close"].rolling(window=window_size).mean()
predictions_flat = future_predictions.flatten()
fig, ax = plt.subplots(figsize=(14, 8))
ax.plot(
recent_df["Date"], recent_df["Close"],
color="gray", linewidth=1.0, label="Harga Aktual (Harian)", alpha=0.5
)
ax.plot(
recent_df["Date"], recent_df["Trend_Aktual"],
color="#1f77b4", linewidth=2.5, label="Tren Harga Aktual", alpha=0.9
)
ax.plot(
future_dates, predictions_flat,
color="#d62728", linewidth=2.5, label="Harga Prediksi (GRU)",
alpha=0.9, marker="o", markersize=4
)
ax.scatter(
recent_df["Date"], recent_df["Close"],
color="black", s=15, alpha=0.6, zorder=5, label="Data Harian Aktual"
)
# garis penghubung trend terakhir ke prediksi pertama
try:
last_trend_date = recent_df["Date"].iloc[-1]
last_trend_price = recent_df["Trend_Aktual"].dropna().iloc[-1]
first_prediction_date = future_dates[0]
first_prediction_price = predictions_flat[0]
ax.plot(
[last_trend_date, first_prediction_date],
[last_trend_price, first_prediction_price],
color="#d62728", linestyle="--", linewidth=2.0, alpha=0.7
)
except Exception:
pass
ax.set_xlabel("Waktu", fontsize=12, fontweight="bold")
ax.set_ylabel("Harga (USD)", fontsize=12, fontweight="bold")
ax.set_title("Analisis Tren Historis dan Prediksi Harga Ethereum", fontsize=16, fontweight="bold", pad=20)
ax.xaxis.set_major_formatter(mdates.DateFormatter("%b %d, %Y")) ax.xaxis.set_major_formatter(mdates.DateFormatter("%b %d, %Y"))
plt.xticks(rotation=45) plt.xticks(rotation=45)
ax.legend() ax.grid(True, alpha=0.3, linestyle="--")
ax.grid(True, alpha=0.3)
handles, labels = ax.get_legend_handles_labels()
order = [2, 0, 1, 3]
if len(handles) == 4:
ax.legend([handles[idx] for idx in order], [labels[idx] for idx in order], loc="upper left", fontsize=11)
else:
ax.legend(loc="upper left", fontsize=11)
plt.tight_layout()
ax.set_facecolor("#f8f9fa")
fig.patch.set_facecolor("white")
return fig return fig
# --- MAIN UI --- # --- Tampilan Antarmuka Aplikasi ---
st.markdown("<div class='app-title'>Prediksi Harga Ethereum (GRU)</div>", unsafe_allow_html=True) st.markdown("<div class='app-title'>Prediksi Harga Ethereum (GRU)</div>", unsafe_allow_html=True)
st.markdown("<div class='app-subtitle'>Data historis & prediksi ETH-USD berbasis GRU</div>", unsafe_allow_html=True) st.markdown("<div class='app-subtitle'>Data historis & prediksi ETH-USD berbasis GRU</div>", unsafe_allow_html=True)
# LOAD DATA df, data_source = load_eth_data()
df, status = load_eth_data()
# Notifikasi Status
if status == "backup":
st.toast("Koneksi Yahoo Gagal. Pakai Backup.", icon="⚠️")
elif status == "error":
st.error("❌ Gagal memuat data (Library gagal & Backup tidak ada).")
st.stop()
# LOAD MODEL
model, scaler = load_gru_assets() model, scaler = load_gru_assets()
if df is not None and model is not None and scaler is not None: # LOGIC UI (TOAST/WARNING) DITARUH DI SINI (DILUAR CACHE)
if data_source == "backup":
st.toast("Koneksi Yahoo lambat. Menggunakan data backup lokal.", icon="⚠️")
elif data_source == "error":
st.error("❌ Gagal memuat data (Online gagal & Backup tidak ada).")
# INFO UPDATE DATA if df is not None and model is not None and scaler is not None:
last_date = df["Date"].max() # Menampilkan tabel data historis
st.info(f"📅 Data Terupdate sampai: **{last_date.strftime('%d %B %Y')}**")
# 1. Tampilkan Data
st.markdown("<div class='card'>", unsafe_allow_html=True) st.markdown("<div class='card'>", unsafe_allow_html=True)
st.markdown("<div class='h-section'>📚 Data Historis Harga Ethereum</div>", unsafe_allow_html=True) st.markdown("<div class='h-section'>📚 Data Historis Harga Ethereum</div>", unsafe_allow_html=True)
st.dataframe(df.tail(10).sort_values("Date", ascending=False), height=300, use_container_width=True) # Tampilkan 10 data terakhir biar kelihatan update st.dataframe(df, height=300, use_container_width=True)
st.markdown("</div>", unsafe_allow_html=True) st.markdown("</div>", unsafe_allow_html=True)
# 2. Chart Historis # Menampilkan visualisasi line chart
st.markdown("<div class='card'>", unsafe_allow_html=True) st.markdown("<div class='card'>", unsafe_allow_html=True)
st.markdown("<div class='h-section'>📈 Visualisasi Harga Historis</div>", unsafe_allow_html=True) st.markdown("<div class='h-section'>📈 Visualisasi Harga Historis</div>", unsafe_allow_html=True)
st.line_chart(df.set_index("Date")["Close"]) st.line_chart(df.rename(columns={"Date": "index"}).set_index("index")["Close"])
st.markdown("</div>", unsafe_allow_html=True) st.markdown("</div>", unsafe_allow_html=True)
# 3. Prediksi
st.markdown("<div class='card'>", unsafe_allow_html=True) st.markdown("<div class='card'>", unsafe_allow_html=True)
st.markdown("<div class='h-section'>🎯 Mulai Prediksi</div>", unsafe_allow_html=True) st.markdown("<div class='h-section'>🎯 Mulai Prediksi Berdasarkan Tanggal</div>", unsafe_allow_html=True)
time_step = int(model.input_shape[1]) time_step = int(model.input_shape[1])
min_date = (df["Date"].min() + timedelta(days=time_step)).date() min_selectable_date = (df["Date"].min() + timedelta(days=time_step)).date()
max_date = df["Date"].max().date() max_selectable_date = df["Date"].max().date()
c1, c2 = st.columns(2) col1, col2 = st.columns(2)
with c1: with col1:
# Default value ke hari ini (max_date) selected_date = st.date_input(
start_date = st.date_input("Mulai tanggal:", value=max_date, min_value=min_date, max_value=max_date) "Pilih tanggal mulai prediksi:",
with c2: value=max_selectable_date,
days = st.slider("Jumlah hari:", 1, 30, 15) min_value=min_selectable_date,
max_value=max_selectable_date,
help=f"Pilih tanggal antara {min_selectable_date} dan {max_selectable_date}"
)
with col2:
prediction_days = st.slider(
"Pilih jumlah hari untuk prediksi (1-30 hari):",
min_value=1, max_value=30, value=15, step=1
)
if st.button("Buat Prediksi"): if st.button("Buat Prediksi", key="predict_button"):
with st.spinner("Memproses..."): if prediction_days < 1:
vals = df[["Close"]].values.astype(float) st.warning("Jumlah hari prediksi minimal **1**. Silakan geser slidernya dulu. 🙂")
scaled = scaler.transform(vals) st.stop()
check_date = pd.to_datetime(start_date) with st.spinner("Memproses dan menjalankan prediksi..."):
# Cari index tanggal # scaling (mengikuti scaler training)
idx = df[df["Date"].dt.date == check_date.date()].index close_values = df[["Close"]].values.astype(float)
scaled_data = scaler.transform(close_values)
if len(idx) > 0:
idx = idx[0] # Cocokkan berdasarkan tanggal (robust)
if idx < time_step: selected_date_dt = pd.to_datetime(selected_date)
st.error(f"Data tidak cukup (butuh {time_step} hari sebelumnya).") mask = df["Date"].dt.date == selected_date_dt.date()
else: idxs = np.where(mask.to_numpy())[0]
seq = scaled[idx-time_step : idx]
pred_scaled = predict_from_sequence_pure(model, seq, days) if len(idxs) == 0:
pred_real = scaler.inverse_transform(pred_scaled) st.error(f"Tanggal {selected_date_dt.strftime('%Y-%m-%d')} tidak ditemukan dalam dataset.")
st.stop()
f_dates = [check_date + timedelta(days=i) for i in range(1, days+1)]
start_index = int(idxs[0])
st.markdown("<div class='card'>", unsafe_allow_html=True)
fig = create_combined_chart(df, check_date, f_dates, pred_real) if start_index - time_step < 0:
st.pyplot(fig) st.error(
f"Tanggal terlalu awal untuk diprediksi. "
res_df = pd.DataFrame({"Tanggal": [d.strftime("%Y-%m-%d") for d in f_dates], "Harga (USD)": pred_real.flatten()}) f"Butuh {time_step} hari data sebelumnya. Pilih tanggal setelah "
st.dataframe(res_df, use_container_width=True) f"{(df['Date'].min() + timedelta(days=time_step)).strftime('%Y-%m-%d')}."
st.markdown("</div>", unsafe_allow_html=True) )
else: st.stop()
st.error("Tanggal tidak ditemukan dalam dataset.")
initial_sequence = scaled_data[start_index - time_step: start_index] # (time_step,1)
# ✅ Prediksi MURNI dari model
future_predictions_scaled = predict_from_sequence_pure(model, initial_sequence, prediction_days)
# ✅ Inverse transform MURNI dari scaler
future_predictions = scaler.inverse_transform(future_predictions_scaled)
# sanity-check
if not np.isfinite(future_predictions).all():
st.error("❌ Hasil prediksi mengandung NaN/Inf. Periksa kompatibilitas model/scaler.")
st.stop()
future_dates = [selected_date_dt + timedelta(days=i) for i in range(1, prediction_days + 1)]
st.markdown("<div class='card'>", unsafe_allow_html=True)
st.subheader("📊 Grafik Prediksi (Historis + Prediksi)")
fig = create_combined_chart(df, selected_date_dt, future_dates, future_predictions)
st.pyplot(fig)
st.markdown("</div>", unsafe_allow_html=True)
st.markdown("<div class='card'>", unsafe_allow_html=True)
st.subheader("🧾 Tabel Detail Prediksi")
prediction_table_df = pd.DataFrame({
"Tanggal": [d.strftime("%Y-%m-%d") for d in future_dates],
"Harga Prediksi (USD)": [f"USD {price[0]:,.0f}" for price in future_predictions]
})
prediction_table_df.index = prediction_table_df.index + 1
st.dataframe(prediction_table_df, use_container_width=True)
st.markdown("</div>", unsafe_allow_html=True)
last_price = float(df.loc[start_index, "Close"])
max_prediction = float(np.max(future_predictions))
min_prediction = float(np.min(future_predictions))
st.info(f"""
📊 **Informasi Prediksi:**
- Harga terakhir pada tanggal {selected_date.strftime('%Y-%m-%d')}: USD {last_price:,.0f}
- Harga prediksi tertinggi: USD {max_prediction:,.0f}
- Harga prediksi terendah: USD {min_prediction:,.0f}
""")
st.markdown("</div>", unsafe_allow_html=True) st.markdown("</div>", unsafe_allow_html=True)
st.markdown("<div class='footer'>Dibuat oleh Muhammad Gilman Nadhif Azmi</div>", unsafe_allow_html=True) st.markdown("<div class='footer'>Dibuat oleh Muhammad Gilman Nadhif Azmi</div>", unsafe_allow_html=True)
elif model is None: elif model is None:
st.error("Gagal memuat Model/Scaler. Pastikan file .h5 dan .pkl ada.") st.error("Gagal memuat model. Pastikan file 'gru_model.h5' ada di folder yang sama dengan aplikasi.")
elif scaler is None:
st.error("Gagal memuat scaler. Pastikan file 'scaler_gru.pkl' ada di folder yang sama dengan aplikasi.")
else:
st.error("Gagal memuat data. Coba cek koneksi internet atau sumber data yfinance.")

View File

@ -709,3 +709,10 @@ Date,Close,High,Low,Open,Volume
2025-12-08,3125.197998046875,3177.86767578125,3043.703857421875,3061.013671875,25262165670 2025-12-08,3125.197998046875,3177.86767578125,3043.703857421875,3061.013671875,25262165670
2025-12-09,3321.114990234375,3395.838623046875,3092.87646484375,3124.942626953125,32012553374 2025-12-09,3321.114990234375,3395.838623046875,3092.87646484375,3124.942626953125,32012553374
2025-12-10,3325.39013671875,3446.622802734375,3290.14697265625,3321.2041015625,30694387989 2025-12-10,3325.39013671875,3446.622802734375,3290.14697265625,3321.2041015625,30694387989
2025-12-11,3237.056884765625,3327.344482421875,3149.034423828125,3324.38671875,29066243707
2025-12-12,3084.172607421875,3265.37255859375,3050.267333984375,3237.025634765625,24391003174
2025-12-13,3116.6953125,3134.849365234375,3080.07861328125,3084.129638671875,9916869400
2025-12-14,3060.5947265625,3128.622802734375,3034.692626953125,3116.743896484375,15619543350
2025-12-15,2964.18310546875,3175.1181640625,2899.685791015625,3060.4814453125,28765976892
2025-12-16,2964.180908203125,2978.92138671875,2890.01171875,2964.379638671875,22709189818
2025-12-17,2933.59375,2969.88525390625,2920.556884765625,2962.631103515625,19631171584

1 Date Close High Low Open Volume
709 2025-12-08 3125.197998046875 3177.86767578125 3043.703857421875 3061.013671875 25262165670
710 2025-12-09 3321.114990234375 3395.838623046875 3092.87646484375 3124.942626953125 32012553374
711 2025-12-10 3325.39013671875 3446.622802734375 3290.14697265625 3321.2041015625 30694387989
712 2025-12-11 3237.056884765625 3327.344482421875 3149.034423828125 3324.38671875 29066243707
713 2025-12-12 3084.172607421875 3265.37255859375 3050.267333984375 3237.025634765625 24391003174
714 2025-12-13 3116.6953125 3134.849365234375 3080.07861328125 3084.129638671875 9916869400
715 2025-12-14 3060.5947265625 3128.622802734375 3034.692626953125 3116.743896484375 15619543350
716 2025-12-15 2964.18310546875 3175.1181640625 2899.685791015625 3060.4814453125 28765976892
717 2025-12-16 2964.180908203125 2978.92138671875 2890.01171875 2964.379638671875 22709189818
718 2025-12-17 2933.59375 2969.88525390625 2920.556884765625 2962.631103515625 19631171584