rishabh5752 commited on
Commit
7df53ef
1 Parent(s): b09dbe8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle
4
+
5
+ # Load the pre-trained model
6
+ with open('model.pkl', 'rb') as file:
7
+ model = pickle.load(file)
8
+
9
+ # Default parameter values
10
+ default_values = [17.99, 10.38, 122.8, 1001, 0.1184, 0.2776, 0.3001, 0.1471, 0.2419, 0.07871,
11
+ 1.095, 0.9053, 8.589, 153.4, 0.006399, 0.04904, 0.05373, 0.01587, 0.03003,
12
+ 0.006193, 25.38, 17.33, 184.6, 2019, 0.1622, 0.6656, 0.7119, 0.2654, 0.4601, 0.1189]
13
+
14
+ # Create a DataFrame with default parameter values
15
+ default_data = pd.DataFrame([default_values],
16
+ columns=['radius_mean', 'texture_mean', 'perimeter_mean', 'area_mean',
17
+ 'smoothness_mean', 'compactness_mean', 'concavity_mean',
18
+ 'concave points_mean', 'symmetry_mean', 'fractal_dimension_mean',
19
+ 'radius_se', 'texture_se', 'perimeter_se', 'area_se', 'smoothness_se',
20
+ 'compactness_se', 'concavity_se', 'concave points_se', 'symmetry_se',
21
+ 'fractal_dimension_se', 'radius_worst', 'texture_worst', 'perimeter_worst',
22
+ 'area_worst', 'smoothness_worst', 'compactness_worst', 'concavity_worst',
23
+ 'concave points_worst', 'symmetry_worst', 'fractal_dimension_worst'])
24
+
25
+ # Set up the Streamlit app
26
+ st.title('Breast Cancer Prediction')
27
+
28
+ # Display the input form with default values
29
+ st.subheader('Input Parameters')
30
+ user_input = st.form(key='user_input_form')
31
+ input_data = user_input.dataframe(default_data)
32
+
33
+ # Make predictions when the 'Predict' button is clicked
34
+ if user_input.form_submit_button('Predict'):
35
+ prediction = model.predict(input_data)
36
+ prediction_label = 'Malignant' if prediction[0] == 1 else 'Benign'
37
+ st.subheader('Prediction')
38
+ st.write(f'The lesion is predicted to be: {prediction_label}')