Search code examples
pythontensorflowkerasregressionkeras-layer

Accuracy for Regression


I am experementing molecular activity prediction as regression model in keras.

x_train.size=6252312
x_train.shape=(1452, 4306)
y_train.shape=(1452, 1)
y_train.size=1452

model = Sequential()
model.add(Dense(100, activation = "relu",  input_shape=(4306,)))
model.add(Dense(50, activation = "relu"))
model.add(Dropout(0.25))
model.add(Dense(25, activation = "relu"))
model.add(Dropout(0.25))
model.add(Dense(1))
 model.compile(
optimizer="adam",
loss="mse",
)
model.summary()
# Train the model
model.fit(
 x_train,
 y_train,
 batch_size=500,
 epochs=900,
 validation_data=(x_test, y_test),
 shuffle=True
)

I run this two or three times, same code, but it show different r2 accuracy-why it shows different accuracy

 1452/1452 [==============================] - 0s 218us/step - loss: 0.5770 - val_loss: 0.1259 
R2-score: 0.47 
    1452/1452 [==============================] - 1s 411us/step - loss: 0.5882 - val_loss: 0.1281 
R2-score: 0.48
    1452/1452 [==============================] - 0s 332us/step - loss: 0.4917 - val_loss: 0.1154 
R2-score: 0.52

How to get the training accuracy.. When training model it shows only loss and val_ loss

And, any suggestion how to improve model accuracy

Thank you


Solution

  • Accuracy makes no sense for a regression problem, it is a metric only valid for classification. You are already using the R2 score which behaves similarly than accuracy but for regression problems. You can also use the mean absolute error (mae).