I develop an ANN model and I think I get good MSE and MAE. But when I want to get R2 score, it is -260!! Is it logical??
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras import regularizers
from keras.callbacks import EarlyStopping
ann_model = Sequential()
ann_model.add(Dense(16, input_shape=(X_train.shape[1],), activation='relu', activity_regularizer=regularizers.l1(0.0001)))
ann_model.add(Dropout(0.1))
ann_model.add(Dense(8, activation='relu'))
ann_model.add(Dense(1, activation='linear'))
ann_model.compile(loss='mean_squared_error', optimizer='adam', metrics=['mae'])
ann_model.summary()
history = ann_model.fit(X_train, y_train, validation_split=0.25, epochs =400, batch_size=16)
note that my problem is regression
I calculate r2 but it is negative
y_pred = ann_model.predict(X_test)
from sklearn.metrics import r2_score
r2 = r2_score(y_test, y_pred)
print('R-squared:', r2)
enter image description here
enter image description here
New contributor
AmirHosein Shirzad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.