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

Error in signif(nevergrad_hp_val[[co]][index], 6) : non-numeric argument to mathematical function #813

Closed
auzaluis opened this issue Sep 12, 2023 · 2 comments
Assignees

Comments

@auzaluis
Copy link

Project Robyn

Demo.R

Describe issue

Error in signif(nevergrad_hp_val[[co]][index], 6) :
non-numeric argument to mathematical function

Provide reproducible example

Libraries

library(tidyverse)
library(Robyn)
library(reticulate)

set.seed(123)

Force multi-core use when running RStudio

Sys.setenv(R_FUTURE_FORK_ENABLE = "true")
options(future.fork.enable = TRUE)

Create virtual environment

conda_create("r-reticulate")

Use the environment created

use_condaenv("r-reticulate", required = T)

Check simulated dataset or load your own dataset

data("dt_simulated_weekly")
head(dt_simulated_weekly)

Check holidays from Prophet

data("dt_prophet_holidays")
head(dt_prophet_holidays)

Directory where you want to export results to (will create new folders)

robyn_directory <- "MyDemo.RDS"

All sign control are now automatically provided: "positive" for media & organic

InputCollect <- robyn_inputs(
dt_input = dt_simulated_weekly,
dt_holidays = dt_prophet_holidays,
date_var = "DATE", # date format must be "2020-01-01"
dep_var = "revenue", # there should be only one dependent variable
dep_var_type = "revenue", # "revenue" (ROI) or "conversion" (CPA)
prophet_vars = c("trend", "season", "holiday"), # "trend","season", "weekday" & "holiday"
prophet_country = "IT", # input country code. Check: dt_prophet_holidays
context_vars = c("competitor_sales_B", "events"), # e.g. competitors, discount, unemployment etc
paid_media_spends = c("tv_S", "ooh_S", "print_S", "facebook_S", "search_S"), # mandatory input
paid_media_vars = c("tv_S", "ooh_S", "print_S", "facebook_I", "search_clicks_P"), # mandatory.
organic_vars = "newsletter", # marketing activity without media spend
factor_vars = c("events"), # force variables in context_vars or organic_vars to be categorical
window_start = "2016-11-23",
window_end = "2018-08-22",
adstock = "geometric" # geometric, weibull_cdf or weibull_pdf.
)
print(InputCollect)

hyperparameter names are based on paid_media_spends names too. See right hyperparameter names:

hyper_names(adstock = InputCollect$adstock, all_media = InputCollect$all_media)

Guide to setup & understand hyperparameters

Example hyperparameters ranges for Geometric adstock

hyperparameters <- list(
facebook_S_alphas = c(0.5, 3),
facebook_S_gammas = c(0.3, 1),
facebook_S_thetas = c(0, 0.3),
print_S_alphas = c(0.5, 3),
print_S_gammas = c(0.3, 1),
print_S_thetas = c(0.1, 0.4),
tv_S_alphas = c(0.5, 3),
tv_S_gammas = c(0.3, 1),
tv_S_thetas = c(0.3, 0.8),
search_S_alphas = c(0.5, 3),
search_S_gammas = c(0.3, 1),
search_S_thetas = c(0, 0.3),
ooh_S_alphas = c(0.5, 3),
ooh_S_gammas = c(0.3, 1),
ooh_S_thetas = c(0.1, 0.4),
newsletter_alphas = c(0.5, 3),
newsletter_gammas = c(0.3, 1),
newsletter_thetas = c(0.1, 0.4),
train_size = c(0.5, 0.8)
)

InputCollect <- robyn_inputs(InputCollect = InputCollect, hyperparameters = hyperparameters)

OutputModels <- robyn_run(
InputCollect = InputCollect, # feed in all model specification
cores = 11, # NULL defaults to (max available - 1)
iterations = 2000, # 2000 recommended for the dummy dataset with no calibration
trials = 5, # 5 recommended for the dummy dataset
ts_validation = TRUE, # 3-way-split time series for NRMSE validation.
add_penalty_factor = FALSE # Experimental feature. Use with caution.
)

Environment & Robyn version

Make sure you're using the latest Robyn version before you post an issue.

  • Check and share Robyn version: packageVersion("Robyn") ? 3.10.3
  • R version (Please, check and share: sessionInfo() or R.version$version.string)
    R version 4.3.1 (2023-06-16 ucrt)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Bolivia.utf8 LC_CTYPE=Spanish_Bolivia.utf8 LC_MONETARY=Spanish_Bolivia.utf8
[4] LC_NUMERIC=C LC_TIME=Spanish_Bolivia.utf8

time zone: America/La_Paz
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] reticulate_1.31 Robyn_3.10.3 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.3
[7] purrr_1.0.2 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.3 tidyverse_2.0.0

loaded via a namespace (and not attached):
[1] gtable_0.3.4 shape_1.4.6 QuickJSR_1.0.5 processx_3.8.2 inline_0.3.19
[6] lattice_0.21-8 callr_3.7.3 tzdb_0.4.0 ps_1.7.5 vctrs_0.6.3
[11] tools_4.3.1 bitops_1.0-7 generics_0.1.3 stats4_4.3.1 parallel_4.3.1
[16] fansi_1.0.4 pkgconfig_2.0.3 prophet_1.0 Matrix_1.6-1 ggridges_0.5.4
[21] rngtools_1.5.2 RcppParallel_5.1.7 lifecycle_1.0.3 compiler_4.3.1 munsell_0.5.0
[26] minpack.lm_1.2-3 codetools_0.2-19 h2o_3.42.0.2 RCurl_1.98-1.12 yaml_2.3.7
[31] glmnet_4.1-8 crayon_1.5.2 pillar_1.9.0 nloptr_2.0.3 StanHeaders_2.26.28
[36] doRNG_1.8.6 iterators_1.0.14 rpart_4.1.19 foreach_1.5.2 rstan_2.26.23
[41] tidyselect_1.2.0 rvest_1.0.3 zip_2.3.0 digest_0.6.33 stringi_1.7.12
[46] splines_4.3.1 grid_4.3.1 colorspace_2.1-0 cli_3.6.1 magrittr_2.0.3
[51] loo_2.6.0 patchwork_1.1.3 pkgbuild_1.4.2 survival_3.5-5 utf8_1.2.3
[56] withr_2.5.0 prettyunits_1.1.1 rappdirs_0.3.3 lares_5.2.2 scales_1.2.1
[61] timechange_0.2.0 extraDistr_1.9.1 httr_1.4.7 matrixStats_1.0.0 rpart.plot_3.1.1
[66] gridExtra_2.3 png_0.1-8 hms_1.1.3 openxlsx_4.2.5.2 doParallel_1.0.17
[71] rlang_1.1.1 Rcpp_1.0.11 glue_1.6.2 xml2_1.3.5 pROC_1.18.4
[76] rstudioapi_0.15.0 jsonlite_1.8.7 R6_2.5.1 plyr_1.8.8

@gufengzhou
Copy link
Contributor

There was a similar issue. Would you please check? #750

@gufengzhou gufengzhou self-assigned this Sep 13, 2023
@auzaluis
Copy link
Author

Ok. I've installed again all the packages and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants