Skip to content

Commit

Permalink
use values_weights instead of just weights for categoricals
Browse files Browse the repository at this point in the history
  • Loading branch information
motus committed Feb 2, 2024
1 parent cb30b7d commit f219178
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"minItems": 1,
"uniqueItems": true
},
"weights": {
"values_weights": {
"type": "array",
"items": {
"type": "number"
Expand Down Expand Up @@ -92,7 +92,7 @@
},
"required": ["type", "default", "range"],
"not": {
"required": ["values", "weights"]
"required": ["values", "values_weights"]
},
"$comment": "TODO: add check that default is in range",
"unevaluatedProperties": false
Expand Down Expand Up @@ -139,7 +139,7 @@
},
"required": ["type", "default", "range"],
"not": {
"required": ["values", "weights"]
"required": ["values", "values_weights"]
},
"$comment": "TODO: add check that default is in range",
"unevaluatedProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"default": "yes",
"meta": {"quote": true},
"values": ["yes", "no"],
"weights": [50, 50]
"values_weights": [50, 50]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/tests/tunable_groups_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"type": "categorical",
"default": "halt",
"values": ["halt", "mwait", "noidle"],
"weights": [33, 33, 33] // FLAML requires uniform weights
"values_weights": [33, 33, 33] // FLAML requires uniform weights
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_categorical_weights() -> None:
{
"type": "categorical",
"values": ["foo", "bar", "baz"],
"weights": [25, 25, 50],
"values_weights": [25, 25, 50],
"default": "foo"
}
"""
Expand All @@ -62,7 +62,7 @@ def test_categorical_weights_wrong_count() -> None:
{
"type": "categorical",
"values": ["foo", "bar", "baz"],
"weights": [50, 50],
"values_weights": [50, 50],
"default": "foo"
}
"""
Expand All @@ -79,7 +79,7 @@ def test_categorical_weights_wrong_values() -> None:
{
"type": "categorical",
"values": ["foo", "bar", "baz"],
"weights": [-1, 50, 50],
"values_weights": [-1, 50, 50],
"default": "foo"
}
"""
Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/mlos_bench/tunables/tunable.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TunableDict(TypedDict, total=False):
values: Optional[List[Optional[str]]]
range: Optional[Union[Sequence[int], Sequence[float]]]
special: Optional[Union[List[int], List[float]]]
weights: Optional[List[float]]
values_weights: Optional[List[float]]
special_weights: Optional[List[float]]
range_weight: Optional[float]
meta: Dict[str, Any]
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, name: str, config: TunableDict):
self._range = config_range
self._special: Union[List[int], List[float]] = config.get("special") or []
self._weights: List[float] = (
config.get("weights") or config.get("special_weights") or []
config.get("values_weights") or config.get("special_weights") or []
)
self._range_weight: Optional[float] = config.get("range_weight")
self._current_value = None
Expand Down

0 comments on commit f219178

Please sign in to comment.