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

test: [RLOS2023] [WIP] add more arguments for reg&cb tests #4619

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions python/tests/assert_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ def assert_prediction(job, **kwargs):
def assert_loss(job, **kwargs):
assert job.status == ExecutionStatus.Success, "job should be successful"
assert type(job[0].loss) == float, "loss should be an float"
if job[0].loss < kwargs["expected_loss"]:
return
assert_almost_equal(job[0].loss, kwargs["expected_loss"], decimal=2)
116 changes: 102 additions & 14 deletions python/tests/test_cb.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,15 @@
"grids": [
{
"#base": [
"--cb 1 -P 10000 --preserve_performance_counters --save_resume"
"--cb 1 --preserve_performance_counters --save_resume"
]
},
{
"--cb_type": [
"ips",
"mtr"
]
},
{
"--cb": [
1
"mtr",
"dr",
"dm"
]
}
],
Expand Down Expand Up @@ -94,19 +91,51 @@
"name": "assert_prediction",
"params": {
"expected_value": [
0.9,
0.1
1,
0
],
"threshold": 0.99
"threshold": 0.8
}
}
],
"grids": [
{
"#base": [
"--cb_explore 2 --epsilon 0.2"
"--cb_explore 2"
]
}
},
"(",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[maybe for on of next PRs] please consider adding parameters that are not affecting learning (logging etc)

{
"--epsilon": [
0.1,
0.2,
0.3
]
},
"+",
{
"--first": [
1,
2
]
},
"+",
{
"--bag": [
5,
6,
7
]
},
"+",
{
"--cover": [
1,
2,
3
]
},
")"
],
"output": [
"--readable_model",
Expand Down Expand Up @@ -148,7 +177,9 @@
0.975,
0.025
],
"threshold": 0.1
"threshold": 0.1,
"atol": 0.1,
"rtol": 0.1
}
}
],
Expand All @@ -157,7 +188,64 @@
"#base": [
"--cb_explore_adf"
]
}
},
"(",
{
Copy link
Member

@ataymano ataymano Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding base learner options to the grid (maybe for one of next PRs)

"--epsilon": [
0.1,
0.2,
0.3
]
},
"+",
ataymano marked this conversation as resolved.
Show resolved Hide resolved
{
"--first": [
1,
2
]
},
"+",
{
"--bag": [
5,
6,
7
]
},
"+",
{
"--cover": [
1,
2,
3
]
},
"+",
{
"--squarecb": [
"--gamma_scale 1000",
"--gamma_scale 10000"
]
},
"+",
{
"--synthcover": [
""
]
},
"+",
{
"--regcb": [
""
]
},
"+",
{
"--softmax": [
""
]
},
")"
],
"output": [
"--readable_model",
Expand Down
4 changes: 3 additions & 1 deletion python/tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ def generate_mathematical_expression_json(config):
if isinstance(item, dict):
if expression and (expression[-1].isdigit()):
expression += " * "
if expression and expression[-1] == ")":
expression += " * "
expression += "a" + str(config.index(item))

elif isinstance(item, str):
if item == "(":
if expression and expression[-1].isdigit():
if expression and (expression[-1].isdigit() or expression[-1] == ")"):
expression += " * "
expression += "("
elif item == "+":
Expand Down
66 changes: 59 additions & 7 deletions python/tests/test_regs.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,76 @@
"grids": [
{
"#base": [
"-P 50000 --preserve_performance_counters --save_resume "
"-P 50000 --preserve_performance_counters --save_resume"
]
},
"(",
ataymano marked this conversation as resolved.
Show resolved Hide resolved
{
"--learning_rate": [
null,
0.1,
0.01,
0.001
],
"--decay_learning_rate": [
null,
1.1,
1,
0.9
],
"--power_t": [
null,
0.5,
ataymano marked this conversation as resolved.
Show resolved Hide resolved
0.6,
0.4
]
},
"+",
"(",
{
"#reg": [
"--freegrad",
"--conjugate_gradient",
"--bfgs --passes 1 --cache"
]
},
"+",
{
"#reg": [
"--coin",
"--ftrl",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] other reductions that may be interesting to add:
--freegrad
--bfgs
--conjugate_gradient

"--coin",
"--pistol"
],
"--ftrl_alpha": [
null,
0.1
],
"--ftrl_beta": [
null,
0.1
]
},
")",
"(",
{
"--loss_function": [
null,
"poisson",
"quantile"
]
},
"+",
{
"--learning_rate": [
0.1,
0.01,
0.001
"--loss_function": [
"expectile"
],
"--expectile_q": [
0.25,
0.5
]
}
},
")",
")"
],
"output": [
"--readable_model",
Expand Down