Spaces:
Sleeping
Sleeping
Update cancer.py
Browse files
cancer.py
CHANGED
|
@@ -71,7 +71,7 @@ with st.sidebar:
|
|
| 71 |
st.session_state['x_train'] = x_train
|
| 72 |
st.success(f"Model Trained Successfully! Accuracy: {accuracy:.2f}")
|
| 73 |
|
| 74 |
-
st.title("🎗️ Cancer Prediction
|
| 75 |
|
| 76 |
st.markdown("""<style>.big-font {font-size:20px !important;}</style>
|
| 77 |
<p class="big-font">Provide patient details below to predict cancer presence:</p>""", unsafe_allow_html=True)
|
|
@@ -93,16 +93,20 @@ with col2:
|
|
| 93 |
input_data = [[age, tumor_size, tumor_grade, symptoms_severity, smoking_history,
|
| 94 |
alcohol_consumption, exercise_frequency, gender, family_history]]
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
else:
|
| 106 |
-
st.
|
| 107 |
-
st.write("Good news! The model predicts that there is no cancer detected. Stay healthy!")
|
| 108 |
-
|
|
|
|
| 71 |
st.session_state['x_train'] = x_train
|
| 72 |
st.success(f"Model Trained Successfully! Accuracy: {accuracy:.2f}")
|
| 73 |
|
| 74 |
+
st.title("🎗️ Cancer Prediction🎗️")
|
| 75 |
|
| 76 |
st.markdown("""<style>.big-font {font-size:20px !important;}</style>
|
| 77 |
<p class="big-font">Provide patient details below to predict cancer presence:</p>""", unsafe_allow_html=True)
|
|
|
|
| 93 |
input_data = [[age, tumor_size, tumor_grade, symptoms_severity, smoking_history,
|
| 94 |
alcohol_consumption, exercise_frequency, gender, family_history]]
|
| 95 |
|
| 96 |
+
f st.button("Predict Cancer Presence"):
|
| 97 |
+
if 'trained_model' in st.session_state:
|
| 98 |
+
model = st.session_state['trained_model']
|
| 99 |
+
x_train = st.session_state['x_train']
|
| 100 |
+
input_df = pd.DataFrame(input_data, columns=x_train_train.columns)
|
| 101 |
+
input_transformed = model.named_steps['preprocessor'].transform(input_df)
|
| 102 |
+
prediction = model.named_steps['classifier'].predict(input_transformed)
|
| 103 |
+
|
| 104 |
+
# Change the title and prediction result
|
| 105 |
+
if prediction[0] == 1:
|
| 106 |
+
st.markdown("<h3 style='color: red;'>Cancer Prediction: Positive 🟥</h3>", unsafe_allow_html=True)
|
| 107 |
+
st.write("Unfortunately, the model predicts the presence of cancer. Please consult a doctor for further advice.")
|
| 108 |
+
else:
|
| 109 |
+
st.markdown("<h3 style='color: green;'>Cancer Prediction: Negative 🟩</h3>", unsafe_allow_html=True)
|
| 110 |
+
st.write("Good news! The model predicts that there is no cancer detected. Stay healthy!")
|
| 111 |
else:
|
| 112 |
+
st.error("Please train a model first!")
|
|
|
|
|
|