Suppose, the following are the first few lines from a dataset for solving a regression problem:
H 7.042 5.781 5.399 -9.118 5.488 7.470 0 0 0 1 0 1 1 3 0 0 0 1 0 0 0 0 0 0 0 0 2.144
H 5.781 5.399 5.373 5.488 5.166 6.452 0 1 1 3 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 2.268
H 5.399 5.373 5.423 5.166 4.852 6.069 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.101
H 5.373 5.423 5.247 4.852 5.164 6.197 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.222
H 5.423 5.247 5.485 5.164 4.943 6.434 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.416
C 5.247 5.485 6.675 4.943 8.103 8.264 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.028
C 5.485 6.675 6.372 8.103 -9.152 9.047 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.235
C 6.675 6.372 5.669 -9.152 -8.536 11.954 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.953
H 6.372 5.669 5.304 -8.536 5.433 6.703 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.233
H 5.669 5.304 5.461 5.433 4.924 6.407 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.313
The left-most column is the class data. The right-most column is Y data. The rest of the features are all angular data.
.
My initial setup for the model was as follows:
def create_model(n_hidden_1, n_hidden_2, num_features):
# create the model
model = Sequential()
model.add(tf.keras.layers.InputLayer(input_shape=(num_features,)))
model.add(tf.keras.layers.Dense(n_hidden_1, activation='relu'))
model.add(tf.keras.layers.Dense(n_hidden_2, activation='relu'))
model.add(tf.keras.layers.Dense(1))
# instantiate the optimizer
opt = keras.optimizers.Adam(learning_rate=LEARNING_RATE)
# compile the model
model.compile(
loss="mean_squared_error",
optimizer=opt,
metrics=["mean_squared_error"]
)
# return model
return model
This model didn't produce the correct outcome. The expected output should be around $0.20$. However, the current setup is producing around $0.80$. These are radian values.
Someone told me that MSE doesn't work in the case of angular data. So, I need to use a custom output layer and a custom error function.
Why doesn't mean square error work in the case of angular data?
How can I solve this issue?