Skip to content

Commit

Permalink
Renamed anomaly detection function and added finetune_loss parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
MMenchero committed May 21, 2024
1 parent f22cd41 commit 4762cdb
Show file tree
Hide file tree
Showing 24 changed files with 35,673 additions and 35,663 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export(.nixtla_data_prep)
export(.validate_exogenous)
export(date_conversion)
export(infer_frequency)
export(nixtla_client_anomaly_detection)
export(nixtla_client_cross_validation)
export(nixtla_client_detect_anomalies)
export(nixtla_client_forecast)
export(nixtla_client_historic)
export(nixtla_client_plot)
Expand Down
4 changes: 3 additions & 1 deletion R/nixtla_client_cross_validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @param n_windows Number of windows to evaluate.
#' @param step_size Step size between each cross validation window. If NULL, it will equal the forecast horizon (h).
#' @param finetune_steps Number of steps used to finetune TimeGPT in the new data.
#' @param finetune_loss Loss function to use for finetuning. Options are: "default", "mae", "mse", "rmse", "mape", and "smape".
#' @param clean_ex_first Clean exogenous signal before making the forecasts using TimeGPT.
#' @param model Model to use, either "timegpt-1" or "timegpt-1-long-horizon". Use "timegpt-1-long-horizon" if you want to forecast more than one seasonal period given the frequency of the data.
#'
Expand All @@ -24,7 +25,7 @@
#' fcst <- nixtlar::nixtla_client_cross_validation(df, h = 8, id_col = "unique_id", n_windows = 5)
#' }
#'
nixtla_client_cross_validation <- function(df, h=8, freq=NULL, id_col=NULL, time_col="ds", target_col="y", X_df=NULL, level=NULL, n_windows=1, step_size=NULL, finetune_steps=0, clean_ex_first=TRUE, model="timegpt-1"){
nixtla_client_cross_validation <- function(df, h=8, freq=NULL, id_col=NULL, time_col="ds", target_col="y", X_df=NULL, level=NULL, n_windows=1, step_size=NULL, finetune_steps=0, finetune_loss="default", clean_ex_first=TRUE, model="timegpt-1"){

# Prepare data ----
names(df)[which(names(df) == time_col)] <- "ds"
Expand Down Expand Up @@ -55,6 +56,7 @@ nixtla_client_cross_validation <- function(df, h=8, freq=NULL, id_col=NULL, time
n_windows = n_windows,
step_size = step_size,
finetune_steps = finetune_steps,
finetune_loss = finetune_loss,
clean_ex_first = clean_ex_first
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' fcst <- nixtlar::nixtla_client_anomaly_detection(df, id_col="unique_id")
#' }
#'
nixtla_client_anomaly_detection <- function(df, freq=NULL, id_col=NULL, time_col="ds", target_col="y", level=c(99), clean_ex_first=TRUE, model="timegpt-1"){
nixtla_client_detect_anomalies <- function(df, freq=NULL, id_col=NULL, time_col="ds", target_col="y", level=c(99), clean_ex_first=TRUE, model="timegpt-1"){

# Prepare data ----
names(df)[which(names(df) == time_col)] <- "ds"
Expand Down
4 changes: 3 additions & 1 deletion R/nixtla_client_forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @param X_df A tsibble or a data frame with future exogenous variables.
#' @param level The confidence levels (0-100) for the prediction intervals.
#' @param finetune_steps Number of steps used to finetune TimeGPT in the new data.
#' @param finetune_loss Loss function to use for finetuning. Options are: "default", "mae", "mse", "rmse", "mape", and "smape".
#' @param clean_ex_first Clean exogenous signal before making the forecasts using TimeGPT.
#' @param add_history Return fitted values of the model.
#' @param model Model to use, either "timegpt-1" or "timegpt-1-long-horizon". Use "timegpt-1-long-horizon" if you want to forecast more than one seasonal period given the frequency of the data.
Expand All @@ -23,7 +24,7 @@
#' fcst <- nixtlar::nixtla_client_forecast(df, h=8, id_col="unique_id", level=c(80,95))
#' }
#'
nixtla_client_forecast <- function(df, h=8, freq=NULL, id_col=NULL, time_col="ds", target_col="y", X_df=NULL, level=NULL, finetune_steps=0, clean_ex_first=TRUE, add_history=FALSE, model="timegpt-1"){
nixtla_client_forecast <- function(df, h=8, freq=NULL, id_col=NULL, time_col="ds", target_col="y", X_df=NULL, level=NULL, finetune_steps=0, finetune_loss="default", clean_ex_first=TRUE, add_history=FALSE, model="timegpt-1"){

# Prepare data ----
names(df)[which(names(df) == time_col)] <- "ds"
Expand All @@ -49,6 +50,7 @@ nixtla_client_forecast <- function(df, h=8, freq=NULL, id_col=NULL, time_col="ds
y = y,
freq = freq,
finetune_steps = finetune_steps,
finetune_loss = finetune_loss,
clean_ex_first = clean_ex_first
)

Expand Down
4 changes: 3 additions & 1 deletion R/nixtla_client_historic.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param target_col Column that contains the target variable.
#' @param level The confidence levels (0-100) for the prediction intervals.
#' @param finetune_steps Number of steps used to finetune TimeGPT in the new data.
#' @param finetune_loss Loss function to use for finetuning. Options are: "default", "mae", "mse", "rmse", "mape", and "smape".
#' @param clean_ex_first Clean exogenous signal before making the forecasts using TimeGPT.
#'
#' @return TimeGPT's forecast for the in-sample period.
Expand All @@ -19,7 +20,7 @@
#' fcst <- nixtlar::nixtla_client_historic(df, id_col="unique_id", level=c(80,95))
#' }
#'
nixtla_client_historic <- function(df, freq=NULL, id_col=NULL, time_col="ds", target_col="y", level=NULL, finetune_steps=0, clean_ex_first=TRUE){
nixtla_client_historic <- function(df, freq=NULL, id_col=NULL, time_col="ds", target_col="y", level=NULL, finetune_steps=0, finetune_loss="default", clean_ex_first=TRUE){

# Prepare data ----
names(df)[which(names(df) == time_col)] <- "ds"
Expand All @@ -43,6 +44,7 @@ nixtla_client_historic <- function(df, freq=NULL, id_col=NULL, time_col="ds", ta
y = y,
freq = freq,
finetune_steps = finetune_steps,
finetune_loss = finetune_loss,
clean_ex_first = clean_ex_first
)

Expand Down
4 changes: 2 additions & 2 deletions R/nixtla_client_plot.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Plot forecast and insample values.
#' Plot the output of the following nixtla_client functions: forecast, historic, anomaly_detection, and cross_validation.
#'
#' @param df A tsibble or a data frame with time series data (insample values).
#' @param fcst A tsibble or a data frame with the TimeGPT point forecast and the prediction intervals (if available).
Expand All @@ -10,7 +10,7 @@
#' @param max_insample_length Max number of insample observations to be plotted.
#' @param plot_anomalies Whether or not to plot anomalies.
#'
#' @return Plot with the forecast and insample values
#' @return Corresponding plot.
#' @export
#'
#' @examples
Expand Down
15 changes: 5 additions & 10 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
## Resubmission 9 Feb 2024
This is a resubmission. In this version I have:

## Resumbmission

## Resubmission 3 Feb 2024
This is a resubmission. In this version I have:
This is a resumbmission. In this version, I have:

* Fixed issue with .Renviron file in vignette to comply with CRAN's policies.

## Resubmission 1 Feb 2024
This is a resubmission. In this version I have:

* Fixed issue with tests that require a secret token to make an API call
- Updated names of functions.
- Fixed issues to comply with CRAN's policies.

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
3 changes: 3 additions & 0 deletions man/nixtla_client_cross_validation.Rd

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

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

3 changes: 3 additions & 0 deletions man/nixtla_client_forecast.Rd

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

3 changes: 3 additions & 0 deletions man/nixtla_client_historic.Rd

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

6 changes: 3 additions & 3 deletions man/nixtla_client_plot.Rd

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

Loading

0 comments on commit 4762cdb

Please sign in to comment.