Ayush Shrivastava commited on
Commit
60bdc2a
·
1 Parent(s): 0733338

changes to Data Set

Browse files
Files changed (4) hide show
  1. app.py +11 -5
  2. plot_1.jpg +0 -0
  3. plot_2.jpg +0 -0
  4. requirements.txt +2 -1
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
  import io
12
 
13
 
@@ -19,7 +20,7 @@ def model_MLP(X_train,y_train,X_test,layers, nodes, activation, solver, rate, it
19
  model = Sequential()
20
 
21
  # Adding first layers.
22
- model.add(Dense(nodes, activation=activation, input_dim=X_train.shape[1]))
23
 
24
  # Adding remaining hidden layers.
25
  for i in range(layers-1):
@@ -82,7 +83,7 @@ if __name__ == '__main__':
82
  with right_column:
83
 
84
  # slider for adding noise.
85
- noise = st.slider('Noise', min_value=0,max_value= 100,value=50,step=10)
86
  # slider for test-train split.
87
  split = st.slider('Test-Train Split', min_value=0.1,max_value= 0.9,value=0.3,step=0.1)
88
  # selectbox for solver/optimizer.
@@ -91,12 +92,15 @@ if __name__ == '__main__':
91
  rate = float(st.selectbox('Learning Rate',('0.001','0.003','0.01','0.03','0.1','0.3','1.0'),index=3))
92
 
93
  # Generating regression data.
94
- X, y = make_regression(n_samples=500, n_features=1, noise=noise,random_state=42,bias=3)
 
 
95
 
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.
@@ -130,6 +134,7 @@ if __name__ == '__main__':
130
 
131
  # write the graph to the app.
132
  st.pyplot(fig1)
 
133
 
134
  with right_graph:
135
 
@@ -137,8 +142,9 @@ if __name__ == '__main__':
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')
 
142
 
143
  # setting the labels and title of the graph.
144
  ax2.set_xlabel('X')
@@ -148,7 +154,7 @@ if __name__ == '__main__':
148
 
149
  # write the graph to the app.
150
  st.pyplot(fig2)
151
-
152
 
153
  # Printing the Errors.
154
  st.subheader('Errors')
 
8
  import matplotlib.pyplot as plt
9
  from keras.layers import Dense
10
  import streamlit as st
11
+ import numpy as np
12
  import io
13
 
14
 
 
20
  model = Sequential()
21
 
22
  # Adding first layers.
23
+ model.add(Dense(nodes, activation=activation, input_dim=1))
24
 
25
  # Adding remaining hidden layers.
26
  for i in range(layers-1):
 
83
  with right_column:
84
 
85
  # slider for adding noise.
86
+ noise = st.slider('Noise', min_value=0,max_value= 100,value=20,step=10)
87
  # slider for test-train split.
88
  split = st.slider('Test-Train Split', min_value=0.1,max_value= 0.9,value=0.3,step=0.1)
89
  # selectbox for solver/optimizer.
 
92
  rate = float(st.selectbox('Learning Rate',('0.001','0.003','0.01','0.03','0.1','0.3','1.0'),index=3))
93
 
94
  # Generating regression data.
95
+ # X, y = make_regression(n_samples=100, n_features=1, noise=noise,random_state=42,bias=3)
96
+ X=np.linspace(0,50,100)
97
+ y = np.sin(X) + X + X*np.random.normal(0,1,100)/5
98
 
99
  # Split data into training and test sets.
100
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=split,random_state=42)
101
 
102
  # Predicting the test data.
103
+ X_test.sort(axis=0)
104
  y_hat,model = model_MLP(X_train,y_train,X_test,layers, nodes, activation, solver, rate, iter)
105
 
106
  # Printing Model Architecture.
 
134
 
135
  # write the graph to the app.
136
  st.pyplot(fig1)
137
+ plt.savefig('plot_1.jpg')
138
 
139
  with right_graph:
140
 
 
142
  st.write('Test Data set')
143
 
144
  fig2, ax2 = plt.subplots(1)
145
+ ax2.scatter(X_test, y_test, label='test',color='blue',alpha=0.6)
146
  ax2.scatter(X_test, y_hat, label='prediction',c='red',alpha=0.6,edgecolors='black')
147
+ ax2.plot(X_test, y_hat, label='prediction',c='red',alpha=0.6)
148
 
149
  # setting the labels and title of the graph.
150
  ax2.set_xlabel('X')
 
154
 
155
  # write the graph to the app.
156
  st.pyplot(fig2)
157
+ plt.savefig('plot_2.jpg')
158
 
159
  # Printing the Errors.
160
  st.subheader('Errors')
plot_1.jpg ADDED
plot_2.jpg ADDED
requirements.txt CHANGED
@@ -2,4 +2,5 @@ scikit-learn==1.2.0
2
  keras==2.12.0
3
  streamlit==1.19.0
4
  tensorflow==2.12.0
5
- matplotlib==3.6.3
 
 
2
  keras==2.12.0
3
  streamlit==1.19.0
4
  tensorflow==2.12.0
5
+ matplotlib==3.6.3
6
+ numpy==1.23.5