Skip to content

Commit

Permalink
add type hints to init for LGBMModel (#4420)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanytak authored Jul 1, 2021
1 parent 6a195a1 commit 962a993
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Scikit-learn wrapper interface for LightGBM."""
import copy
from inspect import signature
from typing import Callable, Dict, Optional, Union

import numpy as np

Expand Down Expand Up @@ -348,13 +349,30 @@ def __call__(self, preds, dataset):
class LGBMModel(_LGBMModelBase):
"""Implementation of the scikit-learn API for LightGBM."""

def __init__(self, boosting_type='gbdt', num_leaves=31, max_depth=-1,
learning_rate=0.1, n_estimators=100,
subsample_for_bin=200000, objective=None, class_weight=None,
min_split_gain=0., min_child_weight=1e-3, min_child_samples=20,
subsample=1., subsample_freq=0, colsample_bytree=1.,
reg_alpha=0., reg_lambda=0., random_state=None,
n_jobs=-1, silent=True, importance_type='split', **kwargs):
def __init__(
self,
boosting_type: str = 'gbdt',
num_leaves: int = 31,
max_depth: int = -1,
learning_rate: float = 0.1,
n_estimators: int = 100,
subsample_for_bin: int = 200000,
objective: Optional[Union[str, Callable]] = None,
class_weight: Optional[Union[Dict, str]] = None,
min_split_gain: float = 0.,
min_child_weight: float = 1e-3,
min_child_samples: int = 20,
subsample: float = 1.,
subsample_freq: int = 0,
colsample_bytree: float = 1.,
reg_alpha: float = 0.,
reg_lambda: float = 0.,
random_state: Optional[Union[int, np.random.RandomState]] = None,
n_jobs: int = -1,
silent: bool = True,
importance_type: str = 'split',
**kwargs
):
r"""Construct a gradient boosting model.
Parameters
Expand Down

0 comments on commit 962a993

Please sign in to comment.