Skip to content

Commit 40fd362

Browse files
authored
Add tweedie objective to LightGBM options (#722)
* Add tweedie objective to LightGBM options Signed-off-by: Ken Hoover <[email protected]> * Add test for tweedie Signed-off-by: Ken Hoover <[email protected]> * Add tweedie to parser objective options Signed-off-by: Ken Hoover <[email protected]> --------- Signed-off-by: Ken Hoover <[email protected]>
1 parent 8425a3d commit 40fd362

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

onnxmltools/convert/lightgbm/_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, booster):
3636
self.operator_name = "LgbmClassifier"
3737
self.classes_ = self._generate_classes(booster)
3838
elif self.objective_.startswith(
39-
("regression", "poisson", "gamma", "quantile", "huber")
39+
("regression", "poisson", "gamma", "quantile", "huber", "tweedie")
4040
):
4141
self.operator_name = "LgbmRegressor"
4242
else:

onnxmltools/convert/lightgbm/operator_converters/LightGbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def convert_lightgbm(scope, operator, container):
559559
n_classes = 1 # Regressor has only one output variable
560560
attrs["post_transform"] = "NONE"
561561
attrs["n_targets"] = n_classes
562-
elif gbm_text["objective"].startswith(("poisson", "gamma")):
562+
elif gbm_text["objective"].startswith(("poisson", "gamma", "tweedie")):
563563
n_classes = 1 # Regressor has only one output variable
564564
attrs["n_targets"] = n_classes
565565
# 'Exp' is not a supported post_transform value in the ONNX spec yet,

tests/lightgbm/test_objective_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ObjectiveTest(unittest.TestCase):
3737
"gamma",
3838
"quantile",
3939
"huber",
40+
"tweedie",
4041
)
4142

4243
@staticmethod

0 commit comments

Comments
 (0)