Trouble with Keras accuracy. Am i doing something wrong? #145902
Unanswered
MichaelWan128
asked this question in
Programming Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
I am learning to create neural networks with keras after learning linear regression with tensorflow but ran into some problems. I would love your assistance.
Below is a stock prediction model.
Below is my training data, testing data is in the same format, just different values.
x_train Features Shape: (216, 13)
y_train Labels Shape: (216,)
0 162.527834 164.212424 159.739895 161.877655 91162800 0.0
1 163.079541 163.680476 157.375606 157.690857 90009200 0.0
2 150.312174 160.429533 149.740792 160.321167 141147500 0.0
3 161.404813 162.665787 158.478955 162.399811 91974200 0.0
4 160.636407 162.961331 160.015766 162.665787 95056600 0.0
.. ... ... ... ... ... ...
211 132.951907 133.159713 128.944050 130.853958 77852100 0.0
212 129.557588 131.041978 128.290909 130.487808 63814900 0.0
213 130.012807 130.042493 127.380484 128.676849 69007800 0.0
214 128.320585 129.666432 124.560134 124.728363 85438400 0.0
215 126.658071 129.122157 126.400782 128.261215 75703700 0.0
0 0.0 36.893018 -0.700552 -0.212853 -0.487699 167.279958
1 0.0 32.308463 -1.356079 -0.441498 -0.914580 167.304257
2 0.0 37.558205 -1.644388 -0.682076 -0.962312 167.464500
3 0.0 41.424354 -1.685715 -0.882804 -0.802911 167.751796
4 0.0 41.919893 -1.677665 -1.041776 -0.635889 167.505843
.. ... ... ... ... ... ...
211 0.0 36.101104 -3.411731 -2.247797 -1.163934 140.001260
212 0.0 35.694681 -3.616761 -2.521590 -1.095171 139.197215
213 0.0 33.675364 -3.880644 -2.793401 -1.087243 138.495099
214 0.0 29.726667 -4.358145 -3.106349 -1.251795 137.746471
215 0.0 36.860489 -4.400767 -3.365233 -1.035534 136.835056
0 167.282366
1 166.003498
2 165.245854
3 164.866381
4 164.572969
.. ...
211 136.929420
212 136.070539
213 135.084713
214 133.703867
215 132.978180
[216 rows x 13 columns]
0 157.690857
1 160.321167
2 162.399811
3 162.665787
4 160.774323
...
211 130.487808
212 128.676849
213 124.728363
214 128.261215
215 128.577881
Below is the code i used to train and evaluate the model:
model = Sequential()
model.add(Dense(13, input_shape=(13,), activation='leaky_relu'))
model.add(Dense(39, activation='leaky_relu'))
model.add(Dense(26, activation='leaky_relu'))
model.add(Dense(1, activation='linear'))
early_stopping = EarlyStopping(monitor="loss", patience=10, min_delta=0.001, restore_best_weights=True)
compile the keras model
model.compile(loss='mean_squared_error', optimizer='adam')
fit the keras model on the dataset
model.fit(x_train, y_train, epochs=150, batch_size=16)
evaluate the keras model
mse = model.evaluate(x_test, y_test)
print(mse)
the loss is always above 1000, and i was wondering if i am doing something wrong.
if you are willing to help me, first of all Thank you so much!, second of all, if any of the information above is lacking or unclear, please tell me!
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions