Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| from utils import load_model, predict | |
| from ui import get_user_input | |
| 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") | |
| st.title("Lung Cancer Risk Predictor") | |
| # 1. Load trained model | |
| model = load_model('./models/model.pkl') | |
| # 2. Collect user input as dataframe | |
| input_df = get_user_input() | |
| st.subheader("Patient Data") | |
| st.write(input_df) | |
| # 3. Make prediction | |
| prediction, proba = predict(model, input_df) | |
| # 4. Display results | |
| st.subheader("Prediction") | |
| print(prediction[0]) | |
| label = 'Cancer' if prediction[0] == 1 else 'No Cancer' | |
| st.write(f"**{label}**") | |
| st.subheader("Prediction Probability") | |
| st.write(f"Probability of Cancer: {proba[0][1]:.2f}") |