class_docstr: LightGBM classifier.
class_docstr_tok: ["LightGBM","classifier","."]
docstr: Docstring is inherited from the LGBMModel.
code: def fit(  # type: ignore[override]
      self,
      X: _LGBM_ScikitMatrixLike,
      y: _LGBM_LabelType,
      sample_weight: Optional[_LGBM_WeightType] = None,
      init_score: Optional[_LGBM_InitScoreType] = None,
      eval_set: Optional[List[_LGBM_ScikitValidSet]] = None,
      eval_names: Optional[List[str]] = None,
      eval_sample_weight: Optional[List[_LGBM_WeightType]] = None,
      eval_class_weight: Optional[List[float]] = None,
      eval_init_score: Optional[List[_LGBM_InitScoreType]] = None,
      eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None,
      feature_name: _LGBM_FeatureNameConfiguration = "auto",
      categorical_feature: _LGBM_CategoricalFeatureConfiguration = "auto",
      callbacks: Optional[List[Callable]] = None,
      init_model: Optional[Union[str, Path, Booster, LGBMModel]] = None,
  ) -> "LGBMClassifier":
      """Docstring is inherited from the LGBMModel."""
      _LGBMAssertAllFinite(y)
      _LGBMCheckClassificationTargets(y)
      self._le = _LGBMLabelEncoder().fit(y)
      _y = self._le.transform(y)
      self._class_map = dict(
          zip(self._le.classes_, self._le.transform(self._le.classes_))
      )
      if isinstance(self.class_weight, dict):
          self._class_weight = {
              self._class_map[k]: v
              for k, v in self.class_weight.items()
          }
  
      self._classes = self._le.classes_
      self._n_classes = len(self._classes)  # type: ignore[arg-type]
      if self.objective is None:
          self._objective = None
  
      # adjust eval metrics to match whether binary or multiclass
      # classification is being performed
      if not callable(eval_metric):
          if isinstance(eval_metric, list):
              eval_metric_list = eval_metric
          elif isinstance(eval_metric, str):
              eval_metric_list = [eval_metric]
          else:
              eval_metric_list = []
          if self._n_classes > 2:
              for index, metric in enumerate(eval_metric_list):
                  if metric in {"logloss", "binary_logloss"}:
                      eval_metric_list[index] = "multi_logloss"
                  elif metric in {"error", "binary_error"}:
                      eval_metric_list[index] = "multi_error"
          else:
              for index, metric in enumerate(eval_metric_list):
                  if metric in {"logloss", "multi_logloss"}:
                      eval_metric_list[index] = "binary_logloss"
                  elif metric in {"error", "multi_error"}:
                      eval_metric_list[index] = "binary_error"
          eval_metric = eval_metric_list
  
      # do not modify args, as it causes errors in model selection tools
      valid_sets: Optional[List[_LGBM_ScikitValidSet]] = None
      if eval_set is not None:
          if isinstance(eval_set, tuple):
              eval_set = [eval_set]
          valid_sets = []
          for valid_x, valid_y in eval_set:
              if valid_x is X and valid_y is y:
                  valid_sets.append((valid_x, _y))
              else:
                  valid_sets.append(
                      (valid_x, self._le.transform(valid_y))
                  )
  
      super().fit(
          X,
          _y,
          sample_weight=sample_weight,
          init_score=init_score,
          eval_set=valid_sets,
          eval_names=eval_names,
          eval_sample_weight=eval_sample_weight,
          eval_class_weight=eval_class_weight,
          eval_init_score=eval_init_score,
          eval_metric=eval_metric,
          feature_name=feature_name,
          categorical_feature=categorical_feature,
          callbacks=callbacks,
          init_model=init_model,
      )
      return self
  
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 for calling the LGBMClassifier obj's underlying member method code with example usage: obj.fit(X, y, sample_weight, init_score, eval_set, eval_names, eval_sample_weight, eval_class_weight, eval_init_score, eval_metric, feature_name, categorical_feature, callbacks, init_model) and returns: self