Allow XGBRanker sklearn interface to use other xgboost ranking objectives (#3848)

This commit is contained in:
Rory Mitchell 2018-11-01 13:34:25 +13:00 committed by GitHub
parent 87f49995be
commit 42200ec03e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -921,7 +921,7 @@ class XGBRanker(XGBModel):
base_score, random_state, seed, missing)
if callable(self.objective):
raise ValueError("custom objective function not supported by XGBRanker")
elif self.objective != "rank:pairwise":
elif "rank:" not in self.objective:
raise ValueError("please use XGBRanker for ranking task")
def fit(self, X, y, group, sample_weight=None, eval_set=None, sample_weight_eval_set=None,