Spaces:
Build error
Build error
rishabh5752
commited on
Commit
•
2257bb8
1
Parent(s):
5a13a6a
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import pickle
|
4 |
from tensorflow.keras.models import Sequential
|
5 |
from tensorflow.keras.layers import Dense, Dropout, Activation
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
model = pickle.load(file)
|
10 |
|
11 |
# Default parameter values
|
12 |
default_values = [17.99, 10.38, 122.8, 1001, 0.1184, 0.2776, 0.3001, 0.1471, 0.2419, 0.07871,
|
@@ -24,21 +22,11 @@ default_data = pd.DataFrame([default_values],
|
|
24 |
'area_worst', 'smoothness_worst', 'compactness_worst', 'concavity_worst',
|
25 |
'concave points_worst', 'symmetry_worst', 'fractal_dimension_worst'])
|
26 |
|
27 |
-
# Set up the Streamlit app
|
28 |
-
st.title('Breast Cancer Prediction')
|
29 |
-
|
30 |
# Display the input form with default values
|
31 |
st.subheader('Input Parameters')
|
32 |
user_input = st.form(key='user_input_form')
|
33 |
input_data = user_input.dataframe(default_data)
|
34 |
|
35 |
-
# Make predictions when the 'Predict' button is clicked
|
36 |
-
if user_input.form_submit_button('Predict'):
|
37 |
-
prediction = model.predict(input_data)
|
38 |
-
prediction_label = 'Malignant' if prediction[0] == 1 else 'Benign'
|
39 |
-
st.subheader('Prediction')
|
40 |
-
st.write(f'The lesion is predicted to be: {prediction_label}')
|
41 |
-
|
42 |
# Implementing ANN
|
43 |
ann_model = Sequential()
|
44 |
ann_model.add(Dense(16, input_dim=30, activation='relu'))
|
@@ -48,7 +36,12 @@ ann_model.add(Dense(1, activation='sigmoid'))
|
|
48 |
# Compiling the model
|
49 |
ann_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
|
50 |
|
51 |
-
#
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
from tensorflow.keras.models import Sequential
|
4 |
from tensorflow.keras.layers import Dense, Dropout, Activation
|
5 |
|
6 |
+
# Set up the Streamlit app
|
7 |
+
st.title('Breast Cancer Prediction')
|
|
|
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,
|
|
|
22 |
'area_worst', 'smoothness_worst', 'compactness_worst', 'concavity_worst',
|
23 |
'concave points_worst', 'symmetry_worst', 'fractal_dimension_worst'])
|
24 |
|
|
|
|
|
|
|
25 |
# Display the input form with default values
|
26 |
st.subheader('Input Parameters')
|
27 |
user_input = st.form(key='user_input_form')
|
28 |
input_data = user_input.dataframe(default_data)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Implementing ANN
|
31 |
ann_model = Sequential()
|
32 |
ann_model.add(Dense(16, input_dim=30, activation='relu'))
|
|
|
36 |
# Compiling the model
|
37 |
ann_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
|
38 |
|
39 |
+
# Load the saved model weights
|
40 |
+
ann_model.load_weights('model_weights.h5')
|
41 |
+
|
42 |
+
# Make predictions when the 'Predict' button is clicked
|
43 |
+
if user_input.form_submit_button('Predict'):
|
44 |
+
prediction = ann_model.predict(input_data)
|
45 |
+
prediction_label = 'Malignant' if prediction[0] >= 0.5 else 'Benign'
|
46 |
+
st.subheader('Prediction')
|
47 |
+
st.write(f'The lesion is predicted to be: {prediction_label}')
|