Skip to content
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
27 changes: 27 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# NOTICE

## bbtcomp (reference implementation)

- Repository: https://github.com/jwainer/bbtcomp/tree/master
- Reference paper: Jacques Wainer, "A Bayesian Bradley-Terry model to compare multiple ML algorithms on multiple data sets", JMLR 24 (2023), http://jmlr.org/papers/v24/22-0907.html

MIT License
Copyright (c) 2022 bbtcomp authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 10 additions & 4 deletions bbttest/bbt/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,25 @@ def is_literal_value(value: object, typx: object) -> bool:


def _validate_params(func):
from inspect import signature
from inspect import Parameter, signature

sig = signature(func)
accepts_kwargs = any(
param.kind == Parameter.VAR_KEYWORD for param in sig.parameters.values()
)

@wraps(func)
def wrapper(*args, **kwargs):
for kwarg in kwargs:
if kwarg not in sig.parameters:
raise ValueError(f"Unexpected keyword argument '{kwarg}'")
if not accepts_kwargs:
for kwarg in kwargs:
if kwarg not in sig.parameters:
raise ValueError(f"Unexpected keyword argument '{kwarg}'")
bound_args = sig.bind(*args, **kwargs)
bound_args.apply_defaults()
for name, value in bound_args.arguments.items():
param = sig.parameters[name]
if param.kind == Parameter.VAR_KEYWORD:
continue
# If type annotation is a Literal, validate the value
if param.annotation is not param.empty and is_literal_value(
value, param.annotation
Expand Down
8 changes: 4 additions & 4 deletions bbttest/bbt/alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _construct_no_paired(
no_pairs = no_algs * (no_algs - 1) // 2
out_array = -1 * np.ones(
(no_pairs, 5), # alg_1, alg_2, 1_wins, 2_wins, ties
dtype=np.float32,
dtype=np.int32,
)
for i, j, k in tqdm(
_gen_pairs(no_algs),
Expand Down Expand Up @@ -79,9 +79,9 @@ def _construct_lrope(
lrope_value: float,
) -> np.ndarray:
logger.debug("Using paired BBT test.")
no_algs = data.shape[1]
no_algs = len(alg_names)
no_pairs = no_algs * (no_algs - 1) // 2
out_array = -1 * np.ones(
out_array = np.zeros(
(no_pairs, 5), # alg_1, alg_2, 1_wins, 2_wins, ties
dtype=np.int32,
)
Expand Down Expand Up @@ -116,7 +116,7 @@ def _solve_ties(table: np.ndarray, tie_solver: str) -> np.ndarray:
if tie_solver == "spread":
tie_val = np.ceil(table[:, TIE_COL] / 2).astype(int)
elif tie_solver == "add":
tie_val = table[:, TIE_COL].astype(int)
tie_val = table[:, TIE_COL]
else:
tie_val = 0
table[:, ALG1_COL] += tie_val
Expand Down
2 changes: 1 addition & 1 deletion bbttest/bbt/py_bbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PyBBT:
def __init__(
self,
local_rope_value: float | None = None,
tie_solver: TieSolverType = "spread",
tie_solver: TieSolverType = "add",
hyper_prior: HyperPriorType = "log_normal",
maximize: bool = True,
scale: float = 1.0,
Expand Down
Loading
Loading