xorbits.lightgbm.LGBMRegressor.fit#

LGBMRegressor.fit(X, y, sample_weight=None, init_score=None, eval_set=None, eval_sample_weight=None, eval_init_score=None, session=None, run_kwargs=None, **kwargs)[source]#

Build a gradient boosting model from the training set (X, y).

Parameters
  • X (numpy array, pandas DataFrame, H2O DataTable's Frame , scipy.sparse, list of lists of int or float of shape = [n_samples, n_features]) – Input feature matrix.

  • y (numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples]) – The target values (class labels in classification, real numbers in regression).

  • sample_weight (numpy array, pandas Series, list of int or float of shape = [n_samples] or None, optional (default=None)) – Weights of training data. Weights should be non-negative.

  • init_score (numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) or shape = [n_samples, n_classes] (for multi-class task) or None, optional (default=None)) – Init score of training data.

  • eval_set (list or None, optional (default=None)) – A list of (X, y) tuple pairs to use as validation sets.

  • eval_names (list of str, or None, optional (default=None) (Not supported yet)) – Names of eval_set.

  • eval_sample_weight (list of array (same types as sample_weight supports), or None, optional (default=None)) – Weights of eval data. Weights should be non-negative.

  • eval_init_score (list of array (same types as init_score supports), or None, optional (default=None)) – Init score of eval data.

  • eval_metric (str, callable, list or None, optional (default=None) (Not supported yet)) – If str, it should be a built-in evaluation metric to use. If callable, it should be a custom evaluation metric, see note below for more details. If list, it can be a list of built-in metrics, a list of custom evaluation metrics, or a mix of both. In either case, the metric from the model parameters will be evaluated and used as well. Default: ‘l2’ for LGBMRegressor, ‘logloss’ for LGBMClassifier, ‘ndcg’ for LGBMRanker.

  • feature_name (list of str, or 'auto', optional (default='auto') (Not supported yet)) – Feature names. If ‘auto’ and data is pandas DataFrame, data columns names are used.

  • categorical_feature (list of str or int, or 'auto', optional (default='auto') (Not supported yet)) – Categorical features. If list of int, interpreted as indices. If list of str, interpreted as feature names (need to specify feature_name as well). If ‘auto’ and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features will be cast to int32 and thus should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. The output cannot be monotonically constrained with respect to a categorical feature. Floating point numbers in categorical features will be rounded towards 0.

  • callbacks (list of callable, or None, optional (default=None) (Not supported yet)) – List of callback functions that are applied at each iteration. See Callbacks in Python API for more information.

  • init_model (str, pathlib.Path, Booster, LGBMModel or None, optional (default=None) (Not supported yet)) – Filename of LightGBM model, Booster instance or LGBMModel instance used for continue training.

Returns

self – Returns self.

Return type

LGBMRegressor

Note

Custom eval function expects a callable with following signatures: func(y_true, y_pred), func(y_true, y_pred, weight) or func(y_true, y_pred, weight, group) and returns (eval_name, eval_result, is_higher_better) or list of (eval_name, eval_result, is_higher_better):

y_truenumpy 1-D array of shape = [n_samples]

The target values.

y_prednumpy 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. In case of custom objective, predicted values are returned before any transformation, e.g. they are raw margin instead of probability of positive class for binary task in this case.

weightnumpy 1-D array of shape = [n_samples]

The weight of samples. Weights should be non-negative.

groupnumpy 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.

eval_namestr

The name of evaluation function (without whitespace).

eval_resultfloat

The eval result.

is_higher_betterbool

Is eval result higher better, e.g. AUC is is_higher_better.

This docstring was copied from lightgbm.sklearn.LGBMRegressor.