Skip to content

Commit

Permalink
Updated electricity dataset and added dataset with exogenous variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
MMenchero committed May 20, 2024
1 parent b87bf32 commit 141e343
Show file tree
Hide file tree
Showing 30 changed files with 297,011 additions and 114,462 deletions.
68 changes: 62 additions & 6 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
#' Electricity short dataset
#' Electricity dataset
#'
#' Contains prices of different electricity markets
#' Contains prices of different electricity markets.
#'
#' @format ## `electricity`
#' A data frame with 3,600 rows and 3 columns:
#' A data frame with 8400 rows and 3 columns:
#' \describe{
#' \item{unique_id}{Unique identifiers of the electricity markets}
#' \item{ds}{Date in format YYYY:MM:DD hh:mm:ss}
#' \item{y}{Price for the given market and date}
#' \item{unique_id}{Unique identifiers of the electricity markets.}
#' \item{ds}{Date in format YYYY:MM:DD hh:mm:ss.}
#' \item{y}{Price for the given market and date.}
#' }
#' @source <https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv>
"electricity"
#'
#' Electricity dataset with exogenous variables
#'
#' Contains prices of different electricity markets with exogenous variables.
#'
#' @format ## `electricity_exo_vars`
#' A data frame with 8400 rows and 12 columns:
#' \describe{
#' \item{unique_id}{Unique identifiers of the electricity markets.}
#' \item{ds}{Date in format YYYY:MM:DD hh:mm:ss.}
#' \item{y}{Price for the given market and date.}
#' \item{Exogenous1}{An external factor influencing prices. For all markets, some form of day-ahead load forecast.}
#' \item{Exogenous2}{An external factor influencing prices.
#' For "BE" and "FR" markets, the day-ahead generation forecast.
#' For "NP", the day-ahead wind generation forecast.
#' For "PJM", the day-ahead load forecast in a specific zone.
#' For "DE", the aggregated day-ahead wind and solar generation forecasts.
#' }
#' \item{day_0}{Binary variable indicating weekday.}
#' \item{day_1}{Binary variable indicating weekday.}
#' \item{day_2}{Binary variable indicating weekday.}
#' \item{day_3}{Binary variable indicating weekday.}
#' \item{day_4}{Binary variable indicating weekday.}
#' \item{day_5}{Binary variable indicating weekday.}
#' \item{day_6}{Binary variable indicating weekday.}
#' }
#' @source <https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv>
"electricity_exo_vars"
#'
#' Future values for the electricity dataset with exogenous variables
#'
#' Contains the future values of the exogenous variables of the electricity dataset (24 steps-ahead). To be used with `electricity_exo_vars`.
#'
#' @format ## `electricity_future_exo_vars`
#' A data frame with 120 rows and 11 columns:
#' \describe{
#' \item{unique_id}{Unique identifiers of the electricity markets.}
#' \item{ds}{Date in format YYYY:MM:DD hh:mm:ss.}
#' \item{Exogenous1}{An external factor influencing prices. For all markets, some form of day-ahead load forecast.}
#' \item{Exogenous2}{An external factor influencing prices.
#' For "BE" and "FR" markets, the day-ahead generation forecast.
#' For "NP", the day-ahead wind generation forecast.
#' For "PJM", the day-ahead load forecast in a specific zone.
#' For "DE", the aggregated day-ahead wind and solar generation forecasts.
#' }
#' \item{day_0}{Binary variable indicating weekday.}
#' \item{day_1}{Binary variable indicating weekday.}
#' \item{day_2}{Binary variable indicating weekday.}
#' \item{day_3}{Binary variable indicating weekday.}
#' \item{day_4}{Binary variable indicating weekday.}
#' \item{day_5}{Binary variable indicating weekday.}
#' \item{day_6}{Binary variable indicating weekday.}
#' }
#' @source <https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-future-ex-vars.csv>
"electricity_future_exo_vars"

3 changes: 2 additions & 1 deletion R/validate_exogenous.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#'
#' @examples
#' \dontrun{
#' Download df and X_df from https://docs.nixtla.io/docs/exogenous_variables and then run
#' df <- nixtlar::electricity_exo_vars
#' X_df <- nixtlar::electricity_future_exo_vars
#' .validate_exogenous(df, h=24, X_df)
#' }
#'
Expand Down
12 changes: 6 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ library(httptest2)
.mockPaths("/tests/mocks")
start_vignette(dir = "/tests/mocks")
options("TIMEGPT_TOKEN"="dummy_token")
options("NIXTLA_API_KEY"="dummy_api_key")
options(digits=7)
knitr::opts_chunk$set(
Expand Down Expand Up @@ -54,17 +54,17 @@ library(nixtlar)
# Load sample dataset
df <- nixtlar::electricity # this can also be a tsibble!
# Set TIMEGPT Token
nixtlar::nixtla_set_token("TIMEGPT TOKEN")
# Set API key
nixtlar::nixtla_set_api_key("Your API here")
# Forecast the next 8 steps using TimeGPT
fcst <- nixtlar::timegpt_forecast(df, h = 8, id_col = "unique_id", level = c(80,95))
fcst <- nixtlar::nixtla_client_forecast(df, h = 8, id_col = "unique_id", level = c(80,95))
# Plot TimeGPT forecast
nixtlar::timegpt_plot(df, fcst, h = 8, id_col = "unique_id", max_insample_length = 100)
nixtlar::nixtla_client_plot(df, fcst, h = 8, id_col = "unique_id", max_insample_length = 100)
```

Using TimeGPT through `nixtlar` requires a token provided by Nixtla. To see how to obtain it and learn about different ways to set it up, please read the [Get Started](https://nixtla.github.io/nixtlar/articles/get-started.html) guide. Here, you can also find a more detailed explanation of how the forecast and plot functions work.
Using TimeGPT through `nixtlar` requires an API key provided by Nixtla. To see how to obtain it and learn about different ways to set it up, please read the [Get Started](https://nixtla.github.io/nixtlar/articles/get-started.html) guide. Here, you can also find a more detailed explanation of how the forecast and plot functions work.

### Main features of `nixtlar`

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ library(nixtlar)
# Load sample dataset
df <- nixtlar::electricity # this can also be a tsibble!

# Set TIMEGPT Token
nixtlar::nixtla_set_token("TIMEGPT TOKEN")
# Set API key
nixtlar::nixtla_set_api_key("Your API here")

# Forecast the next 8 steps using TimeGPT
fcst <- nixtlar::timegpt_forecast(df, h = 8, id_col = "unique_id", level = c(80,95))
fcst <- nixtlar::nixtla_client_forecast(df, h = 8, id_col = "unique_id", level = c(80,95))

# Plot TimeGPT forecast
nixtlar::timegpt_plot(df, fcst, h = 8, id_col = "unique_id", max_insample_length = 100)
nixtlar::nixtla_client_plot(df, fcst, h = 8, id_col = "unique_id", max_insample_length = 100)
```

Using TimeGPT through `nixtlar` requires a token provided by Nixtla. To
see how to obtain it and learn about different ways to set it up, please
read the [Get
Using TimeGPT through `nixtlar` requires an API key provided by Nixtla.
To see how to obtain it and learn about different ways to set it up,
please read the [Get
Started](https://nixtla.github.io/nixtlar/articles/get-started.html)
guide. Here, you can also find a more detailed explanation of how the
forecast and plot functions work.
Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ navbar:
menu:
- text: "Anomaly Detection"
- href: articles/anomaly-detection.html
- text: "Cross validation"
- text: "Cross-Validation"
- href: articles/cross-validation.html
- text: "Historical Forecast"
- href: articles/historical-forecast.html
Expand Down
1 change: 0 additions & 1 deletion data-raw/electricity.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# Electricity dataset

electricity <- read.csv("https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv")
electricity$y <- round(electricity$y, 5)

usethis::use_data(electricity, overwrite = TRUE)
6 changes: 6 additions & 0 deletions data-raw/electricity_exo_vars.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

## Electricity dataset with exogenous variables

electricity_exo_vars <- read.csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-with-ex-vars.csv')

usethis::use_data(electricity_exo_vars, overwrite = TRUE)
5 changes: 5 additions & 0 deletions data-raw/electricity_future_exo_vars.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## code to prepare `electricity_future_exo_vars` dataset goes here

electricity_future_exo_vars <- read.csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-future-ex-vars.csv')

usethis::use_data(electricity_future_exo_vars, overwrite = TRUE)
Binary file modified data/electricity.rda
Binary file not shown.
Binary file added data/electricity_exo_vars.rda
Binary file not shown.
Binary file added data/electricity_future_exo_vars.rda
Binary file not shown.
3 changes: 2 additions & 1 deletion man/dot-validate_exogenous.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/electricity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions man/electricity_exo_vars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions man/electricity_future_exo_vars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 141e343

Please sign in to comment.