class_docstr: Implementation of the scikit-learn API for LightGBM.
class_docstr_tok: ["Implementation","of","the","scikit-learn","API","for","LightGBM","."]
docstr: Construct a gradient boosting model.
  
  Parameters
  ----------
  boosting_type : str, optional (default='gbdt')
      'gbdt', traditional Gradient Boosting Decision Tree.
      'dart', Dropouts meet Multiple Additive Regression Trees.
      'rf', Random Forest.
  num_leaves : int, optional (default=31)
      Maximum tree leaves for base learners.
  max_depth : int, optional (default=-1)
      Maximum tree depth for base learners, <=0 means no limit.
  learning_rate : float, optional (default=0.1)
      Boosting learning rate.
      You can use ``callbacks`` parameter of ``fit`` method to shrink/adapt learning rate
      in training using ``reset_parameter`` callback.
      Note, that this will ignore the ``learning_rate`` argument in training.
  n_estimators : int, optional (default=100)
      Number of boosted trees to fit.
  subsample_for_bin : int, optional (default=200000)
      Number of samples for constructing bins.
  objective : str, callable or None, optional (default=None)
      Specify the learning task and the corresponding learning objective or
      a custom objective function to be used (see note below).
      Default: 'regression' for LGBMRegressor, 'binary' or 'multiclass' for LGBMClassifier, 'lambdarank' for LGBMRanker.
  class_weight : dict, 'balanced' or None, optional (default=None)
      Weights associated with classes in the form ``{class_label: weight}``.
      Use this parameter only for multi-class classification task;
      for binary classification task you may use ``is_unbalance`` or ``scale_pos_weight`` parameters.
      Note, that the usage of all these parameters will result in poor estimates of the individual class probabilities.
      You may want to consider performing probability calibration
      (https://scikit-learn.org/stable/modules/calibration.html) of your model.
      The 'balanced' mode uses the values of y to automatically adjust weights
      inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))``.
      If None, all classes are supposed to have weight one.
      Note, that these weights will be multiplied with ``sample_weight`` (passed through the ``fit`` method)
      if ``sample_weight`` is specified.
  min_split_gain : float, optional (default=0.)
      Minimum loss reduction required to make a further partition on a leaf node of the tree.
  min_child_weight : float, optional (default=1e-3)
      Minimum sum of instance weight (Hessian) needed in a child (leaf).
  min_child_samples : int, optional (default=20)
      Minimum number of data needed in a child (leaf).
  subsample : float, optional (default=1.)
      Subsample ratio of the training instance.
  subsample_freq : int, optional (default=0)
      Frequency of subsample, <=0 means no enable.
  colsample_bytree : float, optional (default=1.)
      Subsample ratio of columns when constructing each tree.
  reg_alpha : float, optional (default=0.)
      L1 regularization term on weights.
  reg_lambda : float, optional (default=0.)
      L2 regularization term on weights.
  random_state : int, RandomState object or None, optional (default=None)
      Random number seed.
      If int, this number is used to seed the C++ code.
      If RandomState or Generator object (numpy), a random integer is picked based on its state to seed the C++ code.
      If None, default seeds in C++ code are used.
  n_jobs : int or None, optional (default=None)
      Number of parallel threads to use for training (can be changed at prediction time by
      passing it as an extra keyword argument).
  
      For better performance, it is recommended to set this to the number of physical cores
      in the CPU.
  
      Negative integers are interpreted as following joblib's formula (n_cpus + 1 + n_jobs), just like
      scikit-learn (so e.g. -1 means using all threads). A value of zero corresponds the default number of
      threads configured for OpenMP in the system. A value of ``None`` (the default) corresponds
      to using the number of physical cores in the system (its correct detection requires
      either the ``joblib`` or the ``psutil`` util libraries to be installed).
  
      .. versionchanged:: 4.0.0
  
  importance_type : str, optional (default='split')
      The type of feature importance to be filled into ``feature_importances_``.
      If 'split', result contains numbers of times the feature is used in a model.
      If 'gain', result contains total gains of splits which use the feature.
  **kwargs
      Other parameters for the model.
      Check http://lightgbm.readthedocs.io/en/latest/Parameters.html for more parameters.
  
      .. warning::
  
          \*\*kwargs is not supported in sklearn, it may cause unexpected issues.
  
  Note
  ----
  A custom objective function can be provided for the ``objective`` parameter.
  In this case, it should have the signature
  ``objective(y_true, y_pred) -> grad, hess``,
  ``objective(y_true, y_pred, weight) -> grad, hess``
  or ``objective(y_true, y_pred, weight, group) -> grad, hess``:
  
      y_true : numpy 1-D array of shape = [n_samples]
          The target values.
      y_pred : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
          The predicted values.
          Predicted values are returned before any transformation,
          e.g. they are raw margin instead of probability of positive class for binary task.
      weight : numpy 1-D array of shape = [n_samples]
          The weight of samples. Weights should be non-negative.
      group : numpy 1-D array
          Group/query data.
          Only used in the learning-to-rank task.
          sum(group) = n_samples.
          For example, if you have a 100-document dataset with ``group = [10, 20, 40, 10, 10, 10]``, that means that you have 6 groups,
          where the first 10 records are in the first group, records 11-30 are in the second group, records 31-70 are in the third group, etc.
      grad : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
          The value of the first order derivative (gradient) of the loss
          with respect to the elements of y_pred for each sample point.
      hess : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
          The value of the second order derivative (Hessian) of the loss
          with respect to the elements of y_pred for each sample point.
  
  For multi-class task, y_pred is a numpy 2-D array of shape = [n_samples, n_classes],
  and grad and hess should be returned in the same format.
code: 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, _LGBM_ScikitCustomObjectiveFunction]
      ] = None,
      class_weight: Optional[Union[Dict, str]] = None,
      min_split_gain: float = 0.0,
      min_child_weight: float = 1e-3,
      min_child_samples: int = 20,
      subsample: float = 1.0,
      subsample_freq: int = 0,
      colsample_bytree: float = 1.0,
      reg_alpha: float = 0.0,
      reg_lambda: float = 0.0,
      random_state: Optional[
          Union[int, np.random.RandomState, "np.random.Generator"]
      ] = None,
      n_jobs: Optional[int] = None,
      importance_type: str = "split",
      **kwargs,
  ):
      r"""Construct a gradient boosting model.
  
      Parameters
      ----------
      boosting_type : str, optional (default='gbdt')
          'gbdt', traditional Gradient Boosting Decision Tree.
          'dart', Dropouts meet Multiple Additive Regression Trees.
          'rf', Random Forest.
      num_leaves : int, optional (default=31)
          Maximum tree leaves for base learners.
      max_depth : int, optional (default=-1)
          Maximum tree depth for base learners, <=0 means no limit.
      learning_rate : float, optional (default=0.1)
          Boosting learning rate.
          You can use ``callbacks`` parameter of ``fit`` method to shrink/adapt learning rate
          in training using ``reset_parameter`` callback.
          Note, that this will ignore the ``learning_rate`` argument in training.
      n_estimators : int, optional (default=100)
          Number of boosted trees to fit.
      subsample_for_bin : int, optional (default=200000)
          Number of samples for constructing bins.
      objective : str, callable or None, optional (default=None)
          Specify the learning task and the corresponding learning objective or
          a custom objective function to be used (see note below).
          Default: 'regression' for LGBMRegressor, 'binary' or 'multiclass' for LGBMClassifier, 'lambdarank' for LGBMRanker.
      class_weight : dict, 'balanced' or None, optional (default=None)
          Weights associated with classes in the form ``{class_label: weight}``.
          Use this parameter only for multi-class classification task;
          for binary classification task you may use ``is_unbalance`` or ``scale_pos_weight`` parameters.
          Note, that the usage of all these parameters will result in poor estimates of the individual class probabilities.
          You may want to consider performing probability calibration
          (https://scikit-learn.org/stable/modules/calibration.html) of your model.
          The 'balanced' mode uses the values of y to automatically adjust weights
          inversely proportional to class frequencies in the input data as ``n_samples / (n_classes * np.bincount(y))``.
          If None, all classes are supposed to have weight one.
          Note, that these weights will be multiplied with ``sample_weight`` (passed through the ``fit`` method)
          if ``sample_weight`` is specified.
      min_split_gain : float, optional (default=0.)
          Minimum loss reduction required to make a further partition on a leaf node of the tree.
      min_child_weight : float, optional (default=1e-3)
          Minimum sum of instance weight (Hessian) needed in a child (leaf).
      min_child_samples : int, optional (default=20)
          Minimum number of data needed in a child (leaf).
      subsample : float, optional (default=1.)
          Subsample ratio of the training instance.
      subsample_freq : int, optional (default=0)
          Frequency of subsample, <=0 means no enable.
      colsample_bytree : float, optional (default=1.)
          Subsample ratio of columns when constructing each tree.
      reg_alpha : float, optional (default=0.)
          L1 regularization term on weights.
      reg_lambda : float, optional (default=0.)
          L2 regularization term on weights.
      random_state : int, RandomState object or None, optional (default=None)
          Random number seed.
          If int, this number is used to seed the C++ code.
          If RandomState or Generator object (numpy), a random integer is picked based on its state to seed the C++ code.
          If None, default seeds in C++ code are used.
      n_jobs : int or None, optional (default=None)
          Number of parallel threads to use for training (can be changed at prediction time by
          passing it as an extra keyword argument).
  
          For better performance, it is recommended to set this to the number of physical cores
          in the CPU.
  
          Negative integers are interpreted as following joblib's formula (n_cpus + 1 + n_jobs), just like
          scikit-learn (so e.g. -1 means using all threads). A value of zero corresponds the default number of
          threads configured for OpenMP in the system. A value of ``None`` (the default) corresponds
          to using the number of physical cores in the system (its correct detection requires
          either the ``joblib`` or the ``psutil`` util libraries to be installed).
  
          .. versionchanged:: 4.0.0
  
      importance_type : str, optional (default='split')
          The type of feature importance to be filled into ``feature_importances_``.
          If 'split', result contains numbers of times the feature is used in a model.
          If 'gain', result contains total gains of splits which use the feature.
      **kwargs
          Other parameters for the model.
          Check http://lightgbm.readthedocs.io/en/latest/Parameters.html for more parameters.
  
          .. warning::
  
              \*\*kwargs is not supported in sklearn, it may cause unexpected issues.
  
      Note
      ----
      A custom objective function can be provided for the ``objective`` parameter.
      In this case, it should have the signature
      ``objective(y_true, y_pred) -> grad, hess``,
      ``objective(y_true, y_pred, weight) -> grad, hess``
      or ``objective(y_true, y_pred, weight, group) -> grad, hess``:
  
          y_true : numpy 1-D array of shape = [n_samples]
              The target values.
          y_pred : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
              The predicted values.
              Predicted values are returned before any transformation,
              e.g. they are raw margin instead of probability of positive class for binary task.
          weight : numpy 1-D array of shape = [n_samples]
              The weight of samples. Weights should be non-negative.
          group : numpy 1-D array
              Group/query data.
              Only used in the learning-to-rank task.
              sum(group) = n_samples.
              For example, if you have a 100-document dataset with ``group = [10, 20, 40, 10, 10, 10]``, that means that you have 6 groups,
              where the first 10 records are in the first group, records 11-30 are in the second group, records 31-70 are in the third group, etc.
          grad : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
              The value of the first order derivative (gradient) of the loss
              with respect to the elements of y_pred for each sample point.
          hess : numpy 1-D array of shape = [n_samples] or numpy 2-D array of shape = [n_samples, n_classes] (for multi-class task)
              The value of the second order derivative (Hessian) of the loss
              with respect to the elements of y_pred for each sample point.
  
      For multi-class task, y_pred is a numpy 2-D array of shape = [n_samples, n_classes],
      and grad and hess should be returned in the same format.
      """
      if not SKLEARN_INSTALLED:
          raise LightGBMError(
              "scikit-learn is required for lightgbm.sklearn. "
              "You must install scikit-learn and restart your session to use this module."
          )
  
      self.boosting_type = boosting_type
      self.objective = objective
      self.num_leaves = num_leaves
      self.max_depth = max_depth
      self.learning_rate = learning_rate
      self.n_estimators = n_estimators
      self.subsample_for_bin = subsample_for_bin
      self.min_split_gain = min_split_gain
      self.min_child_weight = min_child_weight
      self.min_child_samples = min_child_samples
      self.subsample = subsample
      self.subsample_freq = subsample_freq
      self.colsample_bytree = colsample_bytree
      self.reg_alpha = reg_alpha
      self.reg_lambda = reg_lambda
      self.random_state = random_state
      self.n_jobs = n_jobs
      self.importance_type = importance_type
      self._Booster: Optional[Booster] = None
      self._evals_result: _EvalResultDict = {}
      self._best_score: _LGBM_BoosterBestScoreType = {}
      self._best_iteration: int = -1
      self._other_params: Dict[str, Any] = {}
      self._objective = objective
      self.class_weight = class_weight
      self._class_weight: Optional[Union[Dict, str]] = None
      self._class_map: Optional[Dict[int, int]] = None
      self._n_features: int = -1
      self._n_features_in: int = -1
      self._classes: Optional[np.ndarray] = None
      self._n_classes: int = -1
      self.set_params(**kwargs)
  
imports: import copy
  from inspect import signature
  from pathlib import Path
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import scipy.sparse
  from .basic import Booster, Dataset, LightGBMError, _choose_param_value, _ConfigAliases, _LGBM_BoosterBestScoreType, _LGBM_CategoricalFeatureConfiguration, _LGBM_EvalFunctionResultType, _LGBM_FeatureNameConfiguration, _LGBM_GroupType, _LGBM_InitScoreType, _LGBM_LabelType, _LGBM_WeightType, _log_warning
  from .callback import _EvalResultDict, record_evaluation
  from .compat import SKLEARN_INSTALLED, LGBMNotFittedError, _LGBMAssertAllFinite, _LGBMCheckArray, _LGBMCheckClassificationTargets, _LGBMCheckSampleWeight, _LGBMCheckXY, _LGBMClassifierBase, _LGBMComputeSampleWeight, _LGBMCpuCount, _LGBMLabelEncoder, _LGBMModelBase, _LGBMRegressorBase, dt_DataTable, np_random_Generator, pd_DataFrame
  from .engine import train
label_desc: Use image node_id 1 to create a new LGBMModel object from inherited base classes: _LGBMModelBase with example: obj = LGBMModel(boosting_type, num_leaves, max_depth, learning_rate, n_estimators, subsample_for_bin, objective, class_weight, min_split_gain, min_child_weight, min_child_samples, subsample, subsample_freq, colsample_bytree, reg_alpha, reg_lambda, random_state, n_jobs, importance_type)