reichlab / adaptively-weighted-ensemble

Code and manuscript for adaptively weighted ensembles via stacking
GNU General Public License v3.0
8 stars 4 forks source link

fit_stacked_model() not working #54

Open salauer opened 7 years ago

salauer commented 7 years ago

In inst/estimation/xgb-stacking/xgb-stacking-estimation.R:

library(plyr)
library(dplyr)
library(tidyr)
library(ggplot2)
library(xgboost)
library(xgbstack)
library(awes)

loso_preds_path <- "inst/estimation/loso-predictions"
stacking_model_fits_path <- "inst/estimation/xgb-stacking/fits"
component_model_names <- c("kde", "kcde", "sarima")
region="National"
prediction_target="onset"
explanatory_variables="analysis_time_season_week"
nthread=20

xgbstack_fit <-
  fit_stacked_model(
    regions = region,
    prediction_target = prediction_target,
    component_model_names = component_model_names,
    explanatory_variables = explanatory_variables,
    loso_preds_path = loso_preds_path,
    min_child_weight = - 10^10,
    eta = 0.001,
    lambda = 0,
    cv_params = list(
      nrounds = c(1, 10, 100, 500, 1000, 5000, 10000),
      max_depth = 1,
      alpha = c(0, 1, 5, 10, 20, 50),
      gamma = c(0, 1, 10, 100, 1000, 10000)
    ),
    cv_folds = "leave-one-season-out",
    cv_refit = "ttest",
    verbose = 1,
    nthread = nthread
  )

Gives the error:

Error in dim(preds) <- c(num_models, num_obs) : 
  dims [product 336] do not match the length of object [338]

The answer may lie in the fact that for analysis_time_season_week=10 there are only 8 observations when there should be 12 (or at least a number divisible by 3).

salauer commented 7 years ago

same problem for inst/estimation/xgb-stacking/xgb-stacking-unregularized-estimation.R

elray1 commented 7 years ago

I just checked and there aren't any problems with this on my machine. Let's set up a time to look at this on your machine again.

salauer commented 7 years ago

https://stevelauer.youcanbook.me

salauer commented 7 years ago

Seems to be an issue with different versions of xgboost package (most likely) and R (less likely). Would be solved by issue 1 in reichlab/xgboost-mod: https://github.com/reichlab/xgboost-mod/issues/1

salauer commented 7 years ago

The newest version of xgboost depends on R >= 3.3.0, so that may be a relevant factor