TensorFlow Lite for Microcontrollers: Predicting with missing values and categorical variables

I work on a project where sensor data have categorical variables and missing values.
Preprocessing sensor data with, for example, tfp.sts.impute_missing_values and tf.keras.layers.CategoryEncoding alows to train the model with good enough quality.

Yet at inference time, when new (test) data comes directly to the microcontroller that has no resources nor information to do preprocessing similar to the one done on the train data. As a result prediction at the microcontroller fails.

How to solve this?

1 Like

Hi @Dmitri_Kondratiev, If the model is trained on a specific type of data while making inference the data should be in the same format as the training data. Otherwise it is not possible to make predictions. One possible way for your use case is you have to define the pre processing steps inside the model architecture itself, so that the raw can be transformed as the training even though you are passing the raw data, then you can make predictions. Thank You.