Temperature forecasting predicts a future temperature from recent measurements and related observations. A representative task predicts temperature 24 hours ahead from hourly atmospheric pressure, humidity, and other sensor measurements. Its temporal structure includes daily and yearly periodicity, making it a useful setting for timeseries forecasting and recurrent neural networks. section 13.2 section 13.0
The Jena weather dataset
The example uses weather observations from Jena, Germany, recorded every 10 minutes from 2009 to 2016. The dataset contains 420,451 rows and 15 columns: a timestamp plus 14 measurements including temperature, pressure, humidity, wind direction, and wind speed. Plotting the full range exposes yearly periodicity; plotting the first 10 days exposes daily cycles across 144 observations per day. section 13.2
A practical workflow for the forecasting task includes:
- Download and decompress the Jena climate data. section 13.2
- Parse timestamps with the dataset’s fixed Central European Time convention and read weather columns as numeric values. section 13.2
- Inspect rows, columns, and temporal plots before modeling. section 13.2
- Split the ordered observations into 50% training, 25% validation, and 25% test data. section 13.2
- Iterate over sequence length, sampling rate, recurrent-layer units, dropout, optimizer, and feature engineering because performance choices are dataset-dependent. section 13.4
library(tensorflow, exclude = c("shape", "set_random_seed"))
library(tfdatasets, exclude = "shape")
library(dplyr, warn.conflicts = FALSE)
library(keras3)
url <- paste0(
"https://s3.amazonaws.com/keras-datasets/",
"jena_climate_2009_2016.csv.zip"
)
get_file(origin = url) |>
zip::unzip("jena_climate_2009_2016.csv")
Use the listing to obtain the Jena climate archive before inspecting and plotting the forecasting data. section 13.2
