# Use Machine Learning/Neural Network + Distance Measurements to Find the Position of Devices (Localization)

I want to find the position of several devices using at least distance measurements. These measurements are done using a radio, and it might be that not all devices are in radio range (no distance measurement can then be done). All devices are taking turns on being the "distance measurement master", while the rest of the devices are acting as "distance measurement slaves".

The (training) data generated looks something like this (all the numbers are totally random):

master slave_0 slave_(...) slave_n master_x_coordinate master_y_coordinate
0 5684 897 2378 500 3650
1 690 NaN 722 8450 894
2 9875 645 NaN 348 1580
3 1059 269 8952 5697 36
4 598 896 NaN 7836 365

The numbers under slave_x are distances in millimeter, and NaN means that there were no radio contact (no distance measurement done).

I am able to train a model using TensorFlow (Keras) that to my understanding uses regression (Mean Absolute Error):

n_inputs = training_features_normalized.shape[1]
n_outputs = training_labels.to_numpy().shape[1]

model = Sequential()

model.fit(training_features_normalized, training_labels.to_numpy(), verbose=1, epochs=20)


'training_features_normalized' consists of the columns: 'master', 'slave_0', 'slave_(...)' and slave_n (normalization has been done).

'training_labels' consists of the columns: 'master_x_coordinate' and 'master_y_coordinate'.

This trained model gets good at predicting master_x_coordinate and master_y_coordinate for nodes (positions and distances) that are included in the training data, but the model is bad at predicting the position of devices that are not included in the training data.

So my question is:

Is there a way to train a model using this kind of training data so that the model can predict the position of "new" nodes with "new" positions (positions and relating distance measurements that are not included in the training data)?

• this is a problem that seems to have non-unique answers. Eg the range is the radius but many x,y pairs can correspond to exactly same radius ($r^2=x^2+y^2$) – Nikos M. Feb 23 at 19:40
• Thank you for the answer! Then I guess it is not possible to solve this problem using machine learning. – EVRR Feb 26 at 8:51
• It seems so, unless there are enough independnet measurements that can uniquely determine the coords. But it seems this cannot be guaranted – Nikos M. Feb 26 at 11:07