varshitha22 commited on
Commit
a73e2bd
·
verified ·
1 Parent(s): 72b71c2

Update cancer.py

Browse files
Files changed (1) hide show
  1. cancer.py +10 -8
cancer.py CHANGED
@@ -94,13 +94,15 @@ input_data = [[age, tumor_size, tumor_grade, symptoms_severity, smoking_history,
94
  alcohol_consumption, exercise_frequency, gender, family_history]]
95
 
96
  if 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.columns)
101
- input_transformed = model.named_steps['preprocessor'].transform(input_df)
102
- prediction = model.named_steps['classifier'].predict(input_transformed)
103
- st.markdown(f"*Prediction Result: {'🟥 Positive' if prediction[0] == 1 else '🟩 Negative'}*")
 
104
  else:
105
- st.error("Please train a model first!")
 
106
 
 
94
  alcohol_consumption, exercise_frequency, gender, family_history]]
95
 
96
  if st.button("Predict Cancer Presence"):
97
+ input_df = pd.DataFrame(input_data, columns=X_train.columns)
98
+ input_transformed = model.named_steps['preprocessor'].transform(input_df)
99
+ prediction = model.named_steps['classifier'].predict(input_transformed)
100
+
101
+ # Display prediction with styled text and additional message
102
+ if prediction[0] == 1:
103
+ st.markdown("<h3 style='color: red;'>Cancer Prediction: Positive 🟥</h3>", unsafe_allow_html=True)
104
+ st.write("Unfortunately, the model predicts the presence of cancer. Please consult a doctor for further advice.")
105
  else:
106
+ st.markdown("<h3 style='color: green;'>Cancer Prediction: Negative 🟩</h3>", unsafe_allow_html=True)
107
+ st.write("Good news! The model predicts that there is no cancer detected. Stay healthy!")
108