user10750892
user10750892

Reputation:

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

Upvotes: 2

Views: 1279

Answers (2)

VnC
VnC

Reputation: 2016

model.compile( optimizer="adam", loss="mse", metrics=['here you add your metrics'])

Adequate metrics for regression can be found here. Below is a list of those available in keras:

  • Mean Squared Error: mean_squared_error, MSE or mse
  • Mean Absolute Error: mean_absolute_error, MAE, mae
  • Mean Absolute Percentage Error: mean_absolute_percentage_error, MAPE, mape
  • Cosine Proximity: cosine_proximity, cosine

You can have your own custom metrics as well.

Upvotes: 1

Dr. Snoopy
Dr. Snoopy

Reputation: 56347

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).

Upvotes: 3

Related Questions