Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| from sklearn.datasets import load_breast_cancer | |
| from src.inference import predict_one | |
| from src.eda import run_eda # <-- pastikan file src/eda.py sudah ada | |
| st.set_page_config(page_title="Breast Cancer Classifier", layout="wide") | |
| # Tabs: Prediction & EDA | |
| tab_pred, tab_eda = st.tabs(["🏠 Prediction", "📊 EDA"]) | |
| # ======================= | |
| # Tab 1: Prediction | |
| # ======================= | |
| with tab_pred: | |
| st.title("Breast Cancer Classifier (RandomForest + MinMaxScaler)") | |
| data = load_breast_cancer() | |
| features = list(data.feature_names) | |
| st.sidebar.header("Input Features") | |
| vals = [] | |
| cols = st.columns(2) | |
| for i, f in enumerate(features): | |
| default_val = float(np.mean(data.data[:, i])) | |
| with cols[i % 2]: | |
| vals.append( | |
| st.number_input( | |
| f, value=default_val, step=0.01, format="%.4f" | |
| ) | |
| ) | |
| arr = np.array(vals, dtype=float) | |
| if st.button("Predict"): | |
| y = predict_one(arr) | |
| st.success(f"Prediction: **{data.target_names[y]}** (class={y})") | |
| st.caption("0 = malignant, 1 = benign") | |
| # ======================= | |
| # Tab 2: EDA | |
| # ======================= | |
| with tab_eda: | |
| run_eda() | |