import streamlit as st import pandas as pd import numpy as np from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation # Set up the Streamlit app st.title('Breast Cancer Prediction') # 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']) # 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) # Implementing ANN ann_model = Sequential() ann_model.add(Dense(16, input_dim=30, activation='relu')) ann_model.add(Dropout(0.2)) ann_model.add(Dense(1, activation='sigmoid')) # Compiling the model ann_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) # Load the saved model weights ann_model.load_weights('model_weights.h5') # Make predictions when the 'Predict' button is clicked if user_input.form_submit_button('Predict'): input_array = input_data.values.reshape(1, 30) # Convert DataFrame to NumPy array and reshape prediction = ann_model.predict(input_array) prediction_label = 'Malignant' if prediction[0] >= 0.5 else 'Benign' st.subheader('Prediction') st.write(f'The lesion is predicted to be: {prediction_label}')