File size: 1,422 Bytes
639e30d 1157730 bd9f10e 1157730 bd9f10e 1157730 18401f9 1157730 18401f9 1157730 18401f9 1157730 18401f9 1157730 18401f9 28b866e 18401f9 639e30d 1157730 639e30d 1157730 639e30d 1157730 639e30d 1157730 639e30d 1157730 | 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 | import streamlit as st
import pandas as pd
import joblib
import os
# ======================
# LOAD MODEL
# ======================
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
model_path = os.path.join(BASE_DIR, "model.pkl")
model = joblib.load(model_path)
# ======================
# PAGE CONFIG
# ======================
st.set_page_config(
page_title="Breast Cancer Prediction",
page_icon="🎗️",
layout="centered"
)
st.title("🎗️ Breast Cancer Prediction")
st.write("Auto-generated inputs based on trained model features")
# ======================
# GET FEATURE NAMES
# ======================
feature_names = model.feature_names_in_
# ======================
# CREATE INPUTS
# ======================
st.sidebar.header("Input Features")
input_data = {}
for feature in feature_names:
input_data[feature] = st.sidebar.number_input(
feature,
value=float(model.feature_names_in_.shape[0]) # tijdelijk
)
input_df = pd.DataFrame([input_data])
st.subheader("Input Data")
st.write(input_df)
# ======================
# PREDICTION
# ======================
if st.button("Predict"):
prediction = model.predict(input_df)[0]
probability = model.predict_proba(input_df)[0][1]
st.subheader("Result")
if prediction == 1:
st.error(f"⚠️ Malignant Tumor ({probability:.2%})")
else:
st.success(f"✅ Benign Tumor ({1 - probability:.2%})") |