Skip to content

save_theta produces NULL in the history data result #28

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

Open
yanisvdc opened this issue Feb 24, 2025 · 1 comment
Open

save_theta produces NULL in the history data result #28

yanisvdc opened this issue Feb 24, 2025 · 1 comment

Comments

@yanisvdc
Copy link

yanisvdc commented Feb 24, 2025

Hi, thank you for this package,

When using

library(contextual)

horizon       <- 100L
simulations   <- 100L

bandit        <- ContextualLinearBandit$new(k = 4, d = 3, sigma = 0.3)

# Linear CMAB policies comparison

agents <- list(Agent$new(EpsilonGreedyPolicy$new(0.1), bandit, "EGreedy"),
               Agent$new(ContextualEpsilonGreedyPolicy$new(0.1), bandit, "cEGreedy"),
               Agent$new(ContextualLinTSPolicy$new(0.1), bandit, "LinTS"),
               Agent$new(LinUCBDisjointOptimizedPolicy$new(0.6), bandit, "LinUCB"))

simulation     <- Simulator$new(agents, horizon, simulations, do_parallel = TRUE, 
                                save_context=TRUE, save_theta=TRUE)

history        <- simulation$run()

plot(history, type = "cumulative", rate = FALSE, legend_position = "topleft")

result <- history$data

Why are some of the thetas in the result NULL? I believe that there is no theoretical reason for this and that it should be an error when writing the thetas in the result. Would anyone know how to fix this?

Thanks!

@yanisvdc
Copy link
Author

Solved this by using do_parallel = False

simulation     <- Simulator$new(agents, horizon, simulations, do_parallel = FALSE,
                                save_context=TRUE, save_theta=TRUE)

It seems to be an issue with how parallelization returns the results.

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

1 participant