File size: 1,997 Bytes
7df53ef
 
 
 
 
 
6b7cb21
7df53ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import streamlit as st
import pandas as pd
import pickle

# Load the pre-trained model
with open('model.pkl', 'rb') as file:
    model = pickle.load(file, protocol=pickle.HIGHEST_PROTOCOL)

# Default parameter values
default_values = [17.99, 10.38, 122.8, 1001, 0.1184, 0.2776, 0.3001, 0.1471, 0.2419, 0.07871,
                  1.095, 0.9053, 8.589, 153.4, 0.006399, 0.04904, 0.05373, 0.01587, 0.03003,
                  0.006193, 25.38, 17.33, 184.6, 2019, 0.1622, 0.6656, 0.7119, 0.2654, 0.4601, 0.1189]

# Create a DataFrame with default parameter values
default_data = pd.DataFrame([default_values],
                            columns=['radius_mean', 'texture_mean', 'perimeter_mean', 'area_mean',
                                     'smoothness_mean', 'compactness_mean', 'concavity_mean',
                                     'concave points_mean', 'symmetry_mean', 'fractal_dimension_mean',
                                     'radius_se', 'texture_se', 'perimeter_se', 'area_se', 'smoothness_se',
                                     'compactness_se', 'concavity_se', 'concave points_se', 'symmetry_se',
                                     'fractal_dimension_se', 'radius_worst', 'texture_worst', 'perimeter_worst',
                                     'area_worst', 'smoothness_worst', 'compactness_worst', 'concavity_worst',
                                     'concave points_worst', 'symmetry_worst', 'fractal_dimension_worst'])

# Set up the Streamlit app
st.title('Breast Cancer Prediction')

# Display the input form with default values
st.subheader('Input Parameters')
user_input = st.form(key='user_input_form')
input_data = user_input.dataframe(default_data)

# Make predictions when the 'Predict' button is clicked
if user_input.form_submit_button('Predict'):
    prediction = model.predict(input_data)
    prediction_label = 'Malignant' if prediction[0] == 1 else 'Benign'
    st.subheader('Prediction')
    st.write(f'The lesion is predicted to be: {prediction_label}')