Spaces:
Sleeping
Sleeping
Update cancer.py
Browse files
cancer.py
CHANGED
|
@@ -72,7 +72,7 @@ with st.sidebar:
|
|
| 72 |
st.session_state['X_train'] = X_train
|
| 73 |
st.success(f"Model Trained Successfully! Accuracy: {accuracy:.2f}")
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
st.markdown("""<style>.big-font {font-size:20px !important;}</style>
|
| 78 |
<p class="big-font">Provide patient details below to predict cancer presence:</p>""", unsafe_allow_html=True)
|
|
@@ -98,6 +98,8 @@ if st.button("Predict Cancer Presence"):
|
|
| 98 |
if 'trained_model' in st.session_state:
|
| 99 |
model = st.session_state['trained_model']
|
| 100 |
X_train = st.session_state['X_train']
|
|
|
|
|
|
|
| 101 |
input_df = pd.DataFrame(input_data, columns=X_train.columns)
|
| 102 |
input_transformed = model.named_steps['preprocessor'].transform(input_df)
|
| 103 |
prediction = model.named_steps['classifier'].predict(input_transformed)
|
|
@@ -111,3 +113,4 @@ if st.button("Predict Cancer Presence"):
|
|
| 111 |
else:
|
| 112 |
st.error("Please train a model first!")
|
| 113 |
|
|
|
|
|
|
| 72 |
st.session_state['X_train'] = X_train
|
| 73 |
st.success(f"Model Trained Successfully! Accuracy: {accuracy:.2f}")
|
| 74 |
|
| 75 |
+
st.title("🎗️ Cancer Prediction")
|
| 76 |
|
| 77 |
st.markdown("""<style>.big-font {font-size:20px !important;}</style>
|
| 78 |
<p class="big-font">Provide patient details below to predict cancer presence:</p>""", unsafe_allow_html=True)
|
|
|
|
| 98 |
if 'trained_model' in st.session_state:
|
| 99 |
model = st.session_state['trained_model']
|
| 100 |
X_train = st.session_state['X_train']
|
| 101 |
+
|
| 102 |
+
# Reorder input_data columns to match X_train columns
|
| 103 |
input_df = pd.DataFrame(input_data, columns=X_train.columns)
|
| 104 |
input_transformed = model.named_steps['preprocessor'].transform(input_df)
|
| 105 |
prediction = model.named_steps['classifier'].predict(input_transformed)
|
|
|
|
| 113 |
else:
|
| 114 |
st.error("Please train a model first!")
|
| 115 |
|
| 116 |
+
|