Sunday 27 November 2022

Why doesn't mean square error work in case of angular data?

Suppose, the following is a dataset for solving a regression problem:

H   -9.118   5.488   5.166   4.852   5.164   4.943   8.103  -9.152  7.470  6.452  6.069  6.197  6.434  8.264  9.047         2.222
H    5.488   5.166   4.852   5.164   4.943   8.103  -9.152  -8.536  6.452  6.069  6.197  6.434  8.264  9.047 11.954         2.416 
C    5.166   4.852   5.164   4.943   8.103  -9.152  -8.536   5.433  6.069  6.197  6.434  8.264  9.047 11.954  6.703         3.028
C    4.852   5.164   4.943   8.103  -9.152  -8.536   5.433   4.924  6.197  6.434  8.264  9.047 11.954  6.703  6.407        -1.235
C    5.164   4.943   8.103  -9.152  -8.536   5.433   4.924   5.007  6.434  8.264  9.047 11.954  6.703  6.407  6.088        -0.953 
H    4.943   8.103  -9.152  -8.536   5.433   4.924   5.007   5.057  8.264  9.047 11.954  6.703  6.407  6.088  6.410         2.233
H    8.103  -9.152  -8.536   5.433   4.924   5.007   5.057   5.026  9.047 11.954  6.703  6.407  6.088  6.410  6.206         2.313
H   -9.152  -8.536   5.433   4.924   5.007   5.057   5.026   5.154 11.954  6.703  6.407  6.088  6.410  6.206  6.000         2.314
H   -8.536   5.433   4.924   5.007   5.057   5.026   5.154   5.173  6.703  6.407  6.088  6.410  6.206  6.000  6.102         2.244 
H    5.433   4.924   5.007   5.057   5.026   5.154   5.173   5.279  6.407  6.088  6.410  6.206  6.000  6.102  6.195         2.109 

the left-most column is the class 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.

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?



from Why doesn't mean square error work in case of angular data?

No comments:

Post a Comment