Skip to content

Commit 2358e05

Browse files
sdaultonfacebook-github-bot
authored andcommitted
be explicit about task feature in TL (#2918)
Summary: Pull Request resolved: #2918 X-link: facebook/Ax#4021 Previously, the TL adapter added a task feature to `SearchSpaceDigest.task_features`, but not to `SearchSpaceDigest.bounds` or `SearchSpaceDigest.feature_names`. This avoided needing to pass the task feature as a fixed_feature when making predictions or generating. However, there was a bug when using `Normalize` that dropped one non-task feature here: https://github.com/facebook/Ax/blob/main/ax/generators/torch/botorch_modular/surrogate.py#L247-L250 This diff adds the task feature to `SearchSpaceDigest.bounds`, `SearchSpaceDigest.feature_names`, and `MultiTaskDataset.feature_names` in order to be explicity about all features/bounds. This requires also adding the task feature as a fixed feature before generating, predicting, and cross-validating. Reviewed By: saitcakmak Differential Revision: D77905821
1 parent 71f03ea commit 2358e05

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

botorch/utils/datasets.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from pyre_extensions import none_throws
1919
from torch import long, ones, Tensor
2020

21+
TASK_FEATURE_NAME = "task_feature"
22+
2123

2224
class SupervisedDataset:
2325
r"""Base class for datasets consisting of labelled pairs `(X, Y)`
@@ -351,7 +353,9 @@ def __init__(
351353
self.target_outcome_name = target_outcome_name
352354
self.task_feature_index = task_feature_index
353355
self._validate_datasets(datasets=datasets)
354-
self.feature_names = self.datasets[target_outcome_name].feature_names
356+
self.feature_names = self.datasets[target_outcome_name].feature_names.copy()
357+
if task_feature_index is None:
358+
self.feature_names.append(TASK_FEATURE_NAME)
355359
self.outcome_names = [target_outcome_name]
356360

357361
# Check if the datasets have identical feature sets.

0 commit comments

Comments
 (0)