I am using Keras and R for my calibration problem. I have raw temperature time series data of a low-cost measurement device, which has a strong linear relationship with reference measurements of a high-cost device. The measurements of the low-cost device are not as accurate as the measurements of the high-cost device though. Therefore I want to calibrate the raw measurements of the low-cost device considering reference measurements of the high-cost device using LSTM.

I recently bought "Deep Learning with R, Second Edition" to go through the examples in the book to get a better understanding about Deep Learning. LSTM is also introduced there, but they use it for forecasting temperatures. I want to calibrate, not forecast.

The forecast example and source code I use as a base can be found here: https://github.com/t-kalinowski/deep-learning-with-R-2nd-edition-code/blob/main/ch10.R

Basically they prepare the input data in a way to solve their forecasting problem:

sampling_rate <- 6 # keeping only one measurement per hour
sequence_length <- 120 # look back time (observations)
delay <-g # forecast targets (24 hours)
batch_size <- 256

df_to_inputs_and_targets <- function(df) {
  inputs <- df[input_data_colnames] %>%
    normalize_input_data() %>%

  targets <- as.array(df$`T (degC)`)

    head(inputs, -delay),
    tail(targets, -delay)

make_dataset <- function(df) {
  c(inputs, targets) %<-% df_to_inputs_and_targets(df)
    inputs, targets,
    sampling_rate = sampling_rate,
    sequence_length = sequence_length,
    shuffle = TRUE,
    batch_size = batch_size

train_dataset <- make_dataset(train_df)
val_dataset <- make_dataset(val_df)
test_dataset <- make_dataset(test_df)

Because I don't want to forecast, but calibrate, I would guess, that there is no need for a delay as seen in the former code? The target has to be the last element in the reference measurements sequence in my case. I've changed the parameter values accordingly:

sampling_rate <- 1 # keep all measurements
sequence_length <- 120 # look back time (observations)
delay <- sampling_rate * (sequence_length) - 1 # calibration target (last element of sequence)
batch_size <- 256

Do I have the right idea as seen through the changes in the parameters and if not so, please correct me. Thanks!

PS. As far as I've seen, LSTM seems to be exclusively used as a forecasting method when used with low-cost sensors. So it feels like I can't really use it in the way I want to use it.


1 Answer 1


The difference between high-quality sensors and low-quality ones could be regarded as noise.

That's why you can either use a noise suppression algorithm or autoencoders based on high-quality sensors that could calibrate low-quality signals.

Autoencoders are used in many fields including images, and it works also for signals.

In addition to that, you should have low and high-quality sensors that record signals in the same environment, in order to train them correctly by having low-quality data as input and high-quality data as output.

If trained with many samples, you should have eventually good results that convert low-quality data into high ones.

  • $\begingroup$ Does it answer your question? If not, please let me know. $\endgroup$ Aug 23, 2022 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.