multi groups in the constraints (#7711)

This commit is contained in:
Cheng Li 2022-03-01 02:10:15 -08:00 committed by GitHub
parent 1d468e20a4
commit a92e0f6240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -1393,9 +1393,9 @@ class Booster:
+ ",".join(
[feature_idx_mapping[feature_name] for feature_name in constraint]
)
+ "]"
+ "],"
)
return s + "]"
return s[:-1] + "]"
except KeyError as e:
raise ValueError(
"Constrained features are not a subset of training data feature names"

View File

@ -78,6 +78,12 @@ class TestInteractionConstraints:
feature_names=feature_names,
interaction_constraints=constraints)
constraints = [['feature_0', 'feature_1'], ['feature_2']]
feature_names = ['feature_0', 'feature_1', 'feature_2']
self.run_interaction_constraints(tree_method='exact',
feature_names=feature_names,
interaction_constraints=constraints)
@pytest.mark.skipif(**tm.no_sklearn())
def training_accuracy(self, tree_method):
"""Test accuracy, reused by GPU tests."""