Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitokic/07292024/multistep bug #164

Merged
merged 8 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: finnts
Title: Microsoft Finance Time Series Forecasting Framework
Version: 0.4.0.9005
Version: 0.4.0.9006
Authors@R:
c(person(given = "Mike",
family = "Tokic",
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# finnts 0.4.0.9005 (DEVELOPMENT VERSION)
# finnts 0.4.0.9006 (DEVELOPMENT VERSION)

## Improvements

Expand All @@ -8,6 +8,7 @@
- Always save the most accurate model average, regardless if selected as best model. This allows for improved scaling with large data sets.
- Automatically condense large forecasts (+10k time series) into smaller amount of files to make it easier to read forecast outputs
- Improved weighted MAPE calculation across all time series
- Changed default for box_cox argument in `prep_data()` to FALSE

## Bug Fixes

Expand Down
5 changes: 4 additions & 1 deletion R/ensemble_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ ensemble_models <- function(run_info,
parallel_over = "everything"
)
) %>%
base::suppressMessages() %>%
base::suppressWarnings()

best_param <- tune::select_best(tune_results, metric = "rmse")
Expand Down Expand Up @@ -397,7 +398,9 @@ ensemble_models <- function(run_info,
pkgs = inner_packages,
parallel_over = "everything"
)
)
) %>%
base::suppressMessages() %>%
base::suppressWarnings()

final_fcst <- tune::collect_predictions(refit_tbl) %>%
dplyr::rename(
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_cubist.R
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ cubist_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_final <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

if (!is.null(xreg_tbl)) {
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_glmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ glmnet_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_final <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

if (!is.null(xreg_tbl)) {
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_mars.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ mars_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_final <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

if (!is.null(xreg_tbl)) {
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_svm_poly.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ svm_poly_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_final <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

if (!is.null(xreg_tbl)) {
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_svm_rbf.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ svm_rbf_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_final <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

if (!is.null(xreg_tbl)) {
Expand Down
4 changes: 2 additions & 2 deletions R/multistep_xgboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ xgboost_multistep_predict_impl <- function(object, new_data, ...) {

xreg_tbl_temp <- xreg_tbl %>%
dplyr::filter(
Run_Number >= start_val,
Run_Number <= lag_number
Run_Number >= as.numeric(start_val),
Run_Number <= as.numeric(lag_number)
)

xreg_tbl_final <- xreg_tbl_temp %>%
Expand Down
2 changes: 1 addition & 1 deletion R/prep_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ prep_data <- function(run_info,
fiscal_year_start = 1,
clean_missing_values = TRUE,
clean_outliers = FALSE,
box_cox = TRUE,
box_cox = FALSE,
stationary = TRUE,
forecast_approach = "bottoms_up",
parallel_processing = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/run_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ set_run_info <- function(experiment_name = "finn_fcst",
output_tbl <- tibble::tibble(
experiment_name = experiment_name,
run_name = run_name,
created = created,
created = format(created, "%Y-%m-%d %H:%M:%S"),
path = path,
data_output = data_output,
object_output = object_output
Expand Down
9 changes: 8 additions & 1 deletion R/train_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ train_models <- function(run_info,
parallel_over = "everything"
)
) %>%
tune::collect_predictions()
tune::collect_predictions() %>%
base::suppressMessages() %>%
base::suppressWarnings()

# finalize forecast
final_fcst <- refit_tbl %>%
Expand All @@ -534,6 +536,11 @@ train_models <- function(run_info,
dplyr::mutate(Hyperparameter_ID = hyperparameter_id) %>%
dplyr::select(-.row, -.config)

# check for future forecast
if (as.numeric(min(unique(final_fcst$Train_Test_ID))) != 1) {
stop("model is missing future forecast")
}

# undo differencing transformation
if (stationary & model %in% list_multivariate_models()) {
if (combo_hash == "All-Data") {
Expand Down
2 changes: 1 addition & 1 deletion man/prep_data.Rd

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

Loading