Fix monotone constraint with tuple input. (#7891) (#8159)

This commit is contained in:
Jiaming Yuan
2022-08-12 22:05:53 +08:00
committed by GitHub
parent 140c377a96
commit 9c653378e2
2 changed files with 8 additions and 1 deletions

View File

@@ -1403,10 +1403,12 @@ class Booster:
self.set_param(params_processed or {})
def _transform_monotone_constrains(
self, value: Union[Dict[str, int], str]
self, value: Union[Dict[str, int], str, Tuple[int, ...]]
) -> Union[Tuple[int, ...], str]:
if isinstance(value, str):
return value
if isinstance(value, tuple):
return value
constrained_features = set(value.keys())
feature_names = self.feature_names or []