LGBMRegressor拟合函数官方文档

Signature:
lgb.LGBMRegressor.fit(
self,
X,
y,
sample_weight=None,
init_score=None,
eval_set=None,
eval_names=None,
eval_sample_weight=None,
eval_init_score=None,
eval_metric=None,
early_stopping_rounds=None,
verbose=‘warn’,
feature_name=‘auto’,
categorical_feature=‘auto’,
callbacks=None,
init_model=None,
)
Docstring:
Build a gradient boosting model from the training set (X, y).

Parameters

X : array-like or sparse matrix of shape = [n_samples, n_features]
Input feature matrix.
y : array-like of shape = [n_samples]
The target values (class labels in classification, real numbers in regression).
sample_weight : array-like of shape = [n_samples] or None, optional (default=None)
Weights of training data.
init_score : array-like 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)
Names of eval_set.
eval_sample_weight : list of array, or None, optional (default=None)
Weights of eval data.
eval_init_score : list of array, or None, optional (default=None)
Init score of eval data.
eval_metric : str, callable, list or None, optional (default=None)
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.
early_stopping_rounds : int or None, optional (default=None)
Activates early stopping. The model will train until the validation score stops improving.
Validation score needs to improve at least every early_stopping_rounds round(s)
to continue training.
Requires at least one validation data and one metric.
If there’s more than one, will check all of them. But the training data is ignored anyway.
To check only the first metric, set the first_metric_only parameter to True
in additional parameters **kwargs of the model constructor.
verbose : bool or int, optional (default=True)
Requires at least one evaluation data.
If True, the eval metric on the eval set is printed at each boosting stage.
If int, the eval metric on the eval set is printed at every verbose boosting stage.
The last boosting stage or the boosting stage found by using early_stopping_rounds is also printed.

.. rubric:: Example

With ``verbose`` = 4 and at least one item in ``eval_set``,
an evaluation metric is printed every 4 (instead of 1) boosting stages.

feature_name : list of str, or ‘auto’, optional (default=‘auto’)
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’)
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 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.
callbacks : list of callable, or None, optional (default=None)
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)
Filename of LightGBM model, Booster instance or LGBMModel instance used for continue training.

Returns

self : object
Returns self.

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_true : array-like of shape = [n_samples]
    The target values.
y_pred : array-like of shape = [n_samples] or 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.
weight : array-like of shape = [n_samples]
    The weight of samples.
group : array-like
    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_name : str
    The name of evaluation function (without whitespace).
eval_result : float
    The eval result.
is_higher_better : bool
    Is eval result higher better, e.g. AUC is ``is_higher_better``.

For multi-class task, the y_pred is group by class_id first, then group by row_id.
If you want to get i-th row y_pred in j-th class, the access way is y_pred[j * num_data + i].
File: e:\anaconda3\lib\site-packages\lightgbm\sklearn.py
Type: function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值