File size: 864 Bytes
da0d126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import joblib
from utils import preprocess_input, predict_stroke
from ui import input_form, display_result

@st.cache_resource
def load_model(path: str = "./models/model.pkl"):
    """Load the trained classifier from disk."""
    return joblib.load(path)


def local_css(file_name):
    with open(file_name) as f:
        st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)

local_css("styles.css")

def main():
    st.title("Stroke Prediction Demo")
    st.write("Enter patient metrics to predict stroke risk/type.")

    # Get raw numeric inputs
    data = input_form()

    # Preprocess and predict
    model = load_model()
    X = preprocess_input(data)
    label, proba = predict_stroke(model, X)

    # Show result
    display_result(label, proba)

if __name__ == "__main__":
    main()