-
Notifications
You must be signed in to change notification settings - Fork 312
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
Do the numeric values of ordinal ChoiceParameter choices affect the model? #750
Comments
cc @qingfeng10 (as modopt oncall) and @Balandat |
So if we represent ordered choices internally we normalize them to equidistant numbers in In general, once a parameter is defined as an ordinal categorical parameter, I do not believe we allow imposing linear constraints across it and another parameter - simply b/c designating it as categorical means that the values are not directly comparable (within the parameter, values are completely ordered by definition). You could try to do sth like you're suggesting above, but that would require using integer parameters. Is the application here essentially to select and ordered subset of elements from some ordered list? it seems that in such cases with rather complex constraints it might make sense to think about a more custom way of optimizing this rather than trying to express it in the existing parameter & constraint interface. cc @dme65 |
@Balandat, thank you for getting back to me. For some additional context, please see the initial suggestion #710 (comment) and my response #710 (comment). I'm a bit surprised to hear that:
Especially based on the docs description (above) that:
I'm working on a MWE to verify whether ordered constraints can be imposed on numeric ordinal parameters. #710 shows the stack trace for the error that comes with trying to impose an ordered constraint on |
I see now that indeed, Parameter Constraints [are] not supported for ChoiceParameter (Reproducer via Google Colab). I put the full stack trace at #710 (comment) since it also had the stack trace for the categorical variables. You mentioned:
I'm assuming integer parameters probably use a Matern-like kernel by default rather than a Hamming-like kernel. While not necessarily straightforward for me, it seems possible to swap out the Matern kernel with the Hamming kernel. However, I'm not sure how this could be done only for certain parameters (e.g. only I'm definitely open to other ideas for how to optimize this. The data augmentation approach I've been considering in #710 (comment) will probably work for the small dataset (~O |
So this is for ordered categorical variables. For unordered ones we do indeed use the hamming distance.
We pass down some minimal representation (a Ax/ax/models/torch/botorch_modular/utils.py Lines 105 to 115 in 65dc494
Currently this happens automatically based on the parameter type, i.e., there isn't an easy way right now to use a hamming distance kernel for an integer parameter. Since these are rather complex constraints, I wanted to resurface my previous comment:
It may make the most sense to do something custom here, e.g. using a heuristic mixed-discrete optimization strategy operating directly on the set of feasible orderings in the slot. Something like this could potentially be achieved by passing in some callable that just serves as an feasibility check for whether a given slot configuration is feasible, or it may just itself generate the set of feasible orderings. |
@Balandat Is this similar to what you mentioned in #745 (comment)? I agree that a more custom approach seems to be in order. In terms of application, this goes back to the slot-based approach in #727 where there's some degeneracy associated with the space of compositions. |
TL;DR
The docs seem to suggest that ordinal parameters use a Matern 5/2 kernel, so I assume the answer is "yes" it does affect it. Is there a way to change this to Hamming distance so that order constraints can be used with categorical variables? See toy problem below
Toy Problem
Take some
data
based onchoices
which are used to construct choice parameters (slots
) andconstraints
. Thechoices
can go into any of theslots
, andchoices
are constrained to populateslots
in a particular order (e.g.BAC
is not allowed, onlyABC
). The script-version is given in ordinal_example.py.Imports
Choices and Data
Ordinal Encoding
Choice Parameters
Ordered Constraints
Docs suggest ordinal parameters use Matern 5/2 kernel
Based on Support for mixed search spaces and categorical variables (docs):
It seems like ordinal variables will use a Matérn-5/2 kernel by default, in which case I'd assume the numeric choices of the ordinal parameters to play a significant role. Is this the case? How do I replace this with a Hamming distance instead? Is this a flag that could be incorporated into e.g.
ax_client.create_experiment()
or the other APIs?The text was updated successfully, but these errors were encountered: