Skip to content

Commit

Permalink
Added templates for vignettes to test GitHub Actions and fix previous…
Browse files Browse the repository at this point in the history
… issue.
  • Loading branch information
MMenchero committed Dec 28, 2023
1 parent 6c790c4 commit 930a2e4
Show file tree
Hide file tree
Showing 8 changed files with 36,569 additions and 6,320 deletions.
6 changes: 6 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ navbar:
- text: "Articles"
menu:
- text: "Anomaly Detection"
- href: articles/anomaly-detection.html
- text: "Cross validation"
- href: articles/cross-validation.html
- text: "Historical Forecast"
- href: articles/historical-forecast.html

10 changes: 5 additions & 5 deletions vignettes/anomaly-detection.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Anomaly Detection"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{nixtlar}
%\VignetteIndexEntry{Anomaly Detection}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -34,15 +34,15 @@ head(df)
```

```{r}
timegpt_anomalies_df <- timegpt_anomaly_detection(df, id_col = "unique_id", level = c(95))
head(timegpt_anomalies_df)
timegpt_anomalies <- timegpt_anomaly_detection(df, id_col = "unique_id")
head(timegpt_anomalies)
```

## 3. Plot TimeGPT forecast
## 2. Plot TimeGPT forecast
`nixtlar` includes a function to plot the historical data and any output from `timegpt_forecast`, `timegpt_historic`, `timegpt_anomaly_detection` and `timegpt_cross_validation`. If you have long series, you can use `max_insample_length` to only plot the last N historical values (the forecast will always be plotted in full).

```{r}
timegpt_plot(df, timegpt_anomalies_df, id_col = "unique_id", plot_anomalies = TRUE)
timegpt_plot(df, timegpt_anomalies, id_col = "unique_id", plot_anomalies = TRUE)
```

```{r, include=FALSE}
Expand Down
8 changes: 4 additions & 4 deletions vignettes/get-started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Get Started"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{nixtlar}
%\VignetteIndexEntry{Get Started}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -78,15 +78,15 @@ head(df)
To generate a forecast for this dataset, use `timegpt_forecast`. Default names for the time and the target columns are `ds` and `y`. If your time and target columns have different names, specify them with `time_col` and `target_col`. Since it has multiple ids (one for every electricity market), you'll need to specify the name of the column that contains the ids, which in this case is `unique_id`. To do this, simply use `id_col="unique_id"`. You can also choose confidence levels (0-100) for prediction intervals with `level`.

```{r}
timegpt_fcst_df <- timegpt_forecast(df, h = 8, id_col = "unique_id")
head(timegpt_fcst_df)
timegpt_fcst <- timegpt_forecast(df, h = 8, id_col = "unique_id", level = c(80,95))
head(timegpt_fcst)
```

## 3. Plot TimeGPT forecast
`nixtlar` includes a function to plot the historical data and any output from `timegpt_forecast`, `timegpt_historic`, `timegpt_anomaly_detection` and `timegpt_cross_validation`. If you have long series, you can use `max_insample_length` to only plot the last N historical values (the forecast will always be plotted in full).

```{r}
timegpt_plot(df, timegpt_fcst_df, id_col = "unique_id", max_insample_length = 200)
timegpt_plot(df, timegpt_fcst, id_col = "unique_id", max_insample_length = 200)
```

```{r, include=FALSE}
Expand Down
53 changes: 53 additions & 0 deletions vignettes/historical-forecast.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "Historical Forecast"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Historical Forecast}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
library(httptest2)
start_vignette("mocks")
options("TIMEGPT_TOKEN"="dummy_token")
options(digits=7)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.width = 7,
fig.height = 4
)
```

```{r}
library(nixtlar)
```

## 1. TimeGPT Historical Forecast

```{r}
df <- nixtlar::electricity
head(df)
```

```{r}
timegpt_fitted_values <- timegpt_historic(df, id_col = "unique_id", level = c(80,95))
head(timegpt_fitted_values)
```

## 2. Plot TimeGPT forecast
`nixtlar` includes a function to plot the historical data and any output from `timegpt_forecast`, `timegpt_historic`, `timegpt_anomaly_detection` and `timegpt_cross_validation`. If you have long series, you can use `max_insample_length` to only plot the last N historical values (the forecast will always be plotted in full).

```{r}
timegpt_plot(df, timegpt_fitted_values, id_col = "unique_id", max_insample_length = 200)
```

```{r, include=FALSE}
end_vignette()
```




This file was deleted.

Loading

0 comments on commit 930a2e4

Please sign in to comment.