Ayush Shrivastava commited on
Commit
0733338
1 Parent(s): ab8a7de

Adding Model.Arch to app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -8,6 +8,7 @@ from keras.models import Sequential
8
  import matplotlib.pyplot as plt
9
  from keras.layers import Dense
10
  import streamlit as st
 
11
 
12
 
13
 
@@ -43,7 +44,17 @@ def model_MLP(X_train,y_train,X_test,layers, nodes, activation, solver, rate, it
43
  y_hat = model.predict(X_test)
44
 
45
  # Return model.
46
- return y_hat
 
 
 
 
 
 
 
 
 
 
47
 
48
 
49
  if __name__ == '__main__':
@@ -85,6 +96,14 @@ if __name__ == '__main__':
85
  # Split data into training and test sets.
86
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=split,random_state=42)
87
 
 
 
 
 
 
 
 
 
88
  # Plotting the Prediction data.
89
  # creating a container to display the graphs.
90
  with st.container():
@@ -117,9 +136,6 @@ if __name__ == '__main__':
117
  # Plotting the test data.
118
  st.write('Test Data set')
119
 
120
- # Predicting the test data.
121
- y_hat = model_MLP(X_train,y_train,X_test,layers, nodes, activation, solver, rate, iter)
122
-
123
  fig2, ax2 = plt.subplots(1)
124
  ax2.scatter(X_test, y_test, label='test',color='blue',alpha=0.4)
125
  ax2.scatter(X_test, y_hat, label='prediction',c='red',alpha=0.6,edgecolors='black')
@@ -133,6 +149,7 @@ if __name__ == '__main__':
133
  # write the graph to the app.
134
  st.pyplot(fig2)
135
 
 
136
  # Printing the Errors.
137
  st.subheader('Errors')
138
 
 
8
  import matplotlib.pyplot as plt
9
  from keras.layers import Dense
10
  import streamlit as st
11
+ import io
12
 
13
 
14
 
 
44
  y_hat = model.predict(X_test)
45
 
46
  # Return model.
47
+ return y_hat, model
48
+
49
+
50
+
51
+ def get_model_summary(model):
52
+ stream = io.StringIO()
53
+ model.summary(print_fn=lambda x: stream.write(x + '\n'))
54
+ summary_string = stream.getvalue()
55
+ stream.close()
56
+ return summary_string
57
+
58
 
59
 
60
  if __name__ == '__main__':
 
96
  # Split data into training and test sets.
97
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=split,random_state=42)
98
 
99
+ # Predicting the test data.
100
+ y_hat,model = model_MLP(X_train,y_train,X_test,layers, nodes, activation, solver, rate, iter)
101
+
102
+ # Printing Model Architecture.
103
+ st.subheader('Model Architecture')
104
+ # summary = get_model_summary(model)
105
+ st.write(model.summary(print_fn=lambda x: st.text(x)))
106
+
107
  # Plotting the Prediction data.
108
  # creating a container to display the graphs.
109
  with st.container():
 
136
  # Plotting the test data.
137
  st.write('Test Data set')
138
 
 
 
 
139
  fig2, ax2 = plt.subplots(1)
140
  ax2.scatter(X_test, y_test, label='test',color='blue',alpha=0.4)
141
  ax2.scatter(X_test, y_hat, label='prediction',c='red',alpha=0.6,edgecolors='black')
 
149
  # write the graph to the app.
150
  st.pyplot(fig2)
151
 
152
+
153
  # Printing the Errors.
154
  st.subheader('Errors')
155