Skip to content
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

Fix discovering classifier objective #480

Merged
merged 7 commits into from
Aug 19, 2021
14 changes: 10 additions & 4 deletions onnxmltools/convert/xgboost/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ def _get_attributes(booster):
reg = re.compile(b'(multi:[a-z]{1,15})')
objs = list(set(reg.findall(bstate)))
if len(objs) != 1:
raise RuntimeError(
"Unable to guess objective in {}.".format(objs))
kwargs['num_class'] = trees // ntrees
kwargs["objective"] = objs[0].decode('ascii')
if '"name":"binary:logistic"' in str(bstate):
kwargs['num_class'] = 1
kwargs["objective"] = "binary:logistic"
else:
raise RuntimeError(
"Unable to guess objective in %r (trees=%r, ntrees=%r)"
"." % (objs, trees, ntrees))
else:
kwargs['num_class'] = trees // ntrees
kwargs["objective"] = objs[0].decode('ascii')
else:
kwargs['num_class'] = 1
kwargs["objective"] = "binary:logistic"
Expand Down