I'm working for an environmental data lab. I want to predict water pollution using ML(mlp), but now I have a little problem here: I have some data about water pollution and weather condition:
(weather data which means wind speed, temp, pre, and so on)
(another data which means water pollution indicator)
I'm using this code:
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=42, test_size=0.2)
x_test, x_val, y_test, y_val = train_test_split(x_test, y_test, random_state=42,
test_size=0.5)
model = Sequential()
model.add(Dense(10,activation='relu'))
model.add(Dense(10))
model.add(Dense(8))
model.add(Dense(2), ) # input col 2개 이므로 output도 2개
model.compile(loss='mse', optimizer='adam', metrics=['mse'])
model.fit(x_train, y_train, epochs=100, batch_size=1, validation_data=(x_val, y_val))
loss, mse = model.evaluate(x_test, y_test, batch_size=1)
print('acc : ', mse)
y_predict = model.predict(x_test)
print(y_predict)
def RMSE(y_test, y_predict):
return np.sqrt(mean_squared_error(y_test, y_predict))
print('RMSE : ', RMSE(y_test, y_predict))
r2_y_predict = r2_score(y_test, y_predict)
print('R2 : ', r2_y_predict)
There is an error like this:
y_true and y_pred have different number of output (1!=2)
What is causing this error and how can I solve it?