Skip to content

Fixed Exp3Policy #25

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

Closed
wants to merge 2 commits into from
Closed

Fixed Exp3Policy #25

wants to merge 2 commits into from

Conversation

leferrad
Copy link

Solution for issue #24

  • Fixed loop in R/policy_mab_exp3.R
  • Added test for Exp3Policy

@leferrad
Copy link
Author

I'm having this error in CI, which is kind of expected since the tests have fixed checks that are not taking into account the stochastic component of simulations (AFAIK, seeds are not fixed).


R version 4.0.1 (2020-06-06) -- "See Things Now"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> Sys.setenv("R_TESTS" = "")
> 
> library(testthat)
> library(contextual)
> 
> test_check("contextual")
-- 1. Failure: ContextualPrecachingBandit MAB policies (@test_bandits.R#264)  --
history$cumulative$Exp3$cum_regret not equal to 3.5.
1/1 mismatches
[1] 3 - 3.5 == -0.5

-- 2. Failure: History save_csv without filename (@test_history.R#28)  ---------
`csv_comparison_file` not equal to `import_context`.
Component "choice": Mean relative difference: 0.5714286
Component "reward": Mean absolute difference: 1
Component "regret": Mean relative difference: 1
Component "cum_reward": Mean absolute difference: 1
Component "cum_regret": Mean relative difference: 0.6666667
Component "cum_reward_rate": Mean absolute difference: 0.4166667
Component "cum_regret_rate": Mean relative difference: 0.7142857

-- 3. Failure: History save_csv without filename (@test_history.R#37)  ---------
`csv_comparison_file` not equal to `import_file`.
Component "choice": Mean relative difference: 0.5714286
Component "reward": Mean absolute difference: 1
Component "regret": Mean relative difference: 1
Component "cum_reward": Mean absolute difference: 1
Component "cum_regret": Mean relative difference: 0.6666667
Component "cum_reward_rate": Mean absolute difference: 0.4166667
Component "cum_regret_rate": Mean relative difference: 0.7142857

-- 4. Failure: History save_csv with context (@test_history.R#46)  -------------
`csv_comparison_file` not equal to `import_file`.
Component "choice": Mean relative difference: 0.5714286
Component "reward": Mean absolute difference: 1
Component "regret": Mean relative difference: 1
Component "cum_reward": Mean absolute difference: 1
Component "cum_regret": Mean relative difference: 0.6666667
Component "cum_reward_rate": Mean absolute difference: 0.4166667
Component "cum_regret_rate": Mean relative difference: 0.7142857

-- 5. Failure: History save_csv inc theta removal without filename (@test_histor
`csv_comparison_file` not equal to `import_file`.
Component "choice": Mean relative difference: 0.5714286
Component "reward": Mean absolute difference: 1
Component "regret": Mean relative difference: 1
Component "cum_reward": Mean absolute difference: 1
Component "cum_regret": Mean relative difference: 0.6666667
Component "cum_reward_rate": Mean absolute difference: 0.4166667
Component "cum_regret_rate": Mean relative difference: 0.7142857

-- 6. Failure: History save_csv nc theta removal theta with context (@test_histo
`csv_comparison_file` not equal to `import_file`.
Component "choice": Mean relative difference: 0.5714286
Component "reward": Mean absolute difference: 1
Component "regret": Mean relative difference: 1
Component "cum_reward": Mean absolute difference: 1
Component "cum_regret": Mean relative difference: 0.6666667
Component "cum_reward_rate": Mean absolute difference: 0.4166667
Component "cum_regret_rate": Mean relative difference: 0.7142857

-- 7. Failure: Exp3Policy simulation (@test_policies.R#35)  --------------------
history$cumulative$Exp3$cum_reward not equal to 7.5.
1/1 mismatches
[1] 7.75 - 7.5 == 0.25

-- 8. Failure: Exp3Policy simulation (@test_policies.R#36)  --------------------
history$cumulative$Exp3$cum_regret not equal to 10.8.
1/1 mismatches
[1] 10.4 - 10.8 == -0.35

== testthat results  ===========================================================
[ OK: 130 | SKIPPED: 1 | WARNINGS: 5 | FAILED: 8 ]
1. Failure: ContextualPrecachingBandit MAB policies (@test_bandits.R#264) 
2. Failure: History save_csv without filename (@test_history.R#28) 
3. Failure: History save_csv without filename (@test_history.R#37) 
4. Failure: History save_csv with context (@test_history.R#46) 
5. Failure: History save_csv inc theta removal without filename (@test_history.R#83) 
6. Failure: History save_csv nc theta removal theta with context (@test_history.R#92) 
7. Failure: Exp3Policy simulation (@test_policies.R#35) 
8. Failure: Exp3Policy simulation (@test_policies.R#36) 

Error: testthat unit tests failed
Execution halted

What is strange is that not only the new test is failing but also the other ones that were already deployed in later versions.

@robinvanemden could you provide more info about a possible solution?

@robinvanemden
Copy link
Member

@leferrad Thanks for your pull request - much appreciated! I've been rather busy, but I will make sure to check it out later this week!

@robinvanemden
Copy link
Member

Hi @leferrad - I just added you fix to and related updates to the test in this commit.

It will be part of our next CRAN package release - thanks again!

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

Successfully merging this pull request may close these issues.

2 participants