参数
----------
X : 数组类型矩阵 形状 = [n_samples, n_features]
输入特征矩阵
y : 数组类型 形状 = [n_samples]
目标值 (分类模型中是类标签, 回归模型是真实值).
sample_weight : 数组类型 形状 = [n_samples] optional (default=None)
训练数据的权重
init_score : 数组类型 形状 = [n_samples] optional (default=None)
训练数据的初始分数
group : 数组类型 或者 None, optional (default=None)
训练数据的组数据
eval_set : list or None, optional (default=None)
使用(X,y) 元组作为验证集
eval_names : list of strings or None, optional (default=None)
验证集的名称
eval_sample_weight : list of arrays or None, optional (default=None)
验证集的权重(回归模型)
eval_class_weight : list or None, optional (default=None)
验证集标签的权重 (分类模型)
eval_init_score : list of arrays or None, optional (default=None)
验证集初始分数
eval_group : list of arrays or None, optional (default=None)
验证集组数据
eval_metric : string, list of strings, callable or None, optional (default=None)
如果为字符串,则应使用内置评估指标。
如何为 可执行对象, 则是自定义评估指标
其他情况, 字符串和可执行对象的列表
默认情况: LGBMRegressor使用L2, LGBMClassifier使用logloss, LGBMRanker使用ndcg
early_stopping_rounds : int or None, optional (default=None)
如果验证的分数不再下降,达到 early_stopping_rounds 次了,依旧没有下降,那么终止训练
至少需要一个验证数据和一个指标。
如果有多个指标(eval_metric是list,且长度大于1), 那么将检查所有。
如果只想检查第一个指标,那么需要设置first_metric_only = True
verbose : bool or int, optional (default=True)
至少需要一个验证数据
如果为True, 评估集上的评估指标会在每个提升阶段打印出来。
如果为 int, 每隔多少次打印
如果训练提前停止了,也会打印。 这个提前停止是通过early_stopping_rounds设置的
feature_name : list of strings or 'auto', optional (default='auto')
特征名称。 字符串列表 或者 auto
如果为 'auto' 且 数据是 pandas DataFrame, 那么则使用数据列名
categorical_feature : list of strings or int, or 'auto', optional (default='auto')
分类特征
如果是整数列表,则使用索引
如果是字符串列表, 则像指定 feature_name 一样
如果为 'auto' 且 数据是 pandas DataFrame, 则使用无序分类列
所有的类别特征值应该小于 2147483647
较大的值会占用内存。 考虑使用从零开始的连续整数。
分类特征中的所有负值都将被视为缺失值
不能相对于分类特征单调约束输出
callbacks : list of callback functions or None, optional (default=None)
回调函数列表。 每次迭代都会调用
返回值: 模型self
============================================================
预测predict
参数
----------
X : 数组类型矩阵 形状 = [n_samples, n_features]
输入特征矩阵
raw_score : bool, optional (default=False)
是否预测原始分数
num_iteration : int or None, optional (default=None)
限制预测中的迭代次数。
如果为 None, 如果存在最好的迭代次数,则使用最好的迭代次数; 其他情况, 所有的树被使用
如果 <= 0, 所有的树被使用 (不限制).
pred_leaf : bool, optional (default=False)
是否预测叶指数
pred_contrib : bool, optional (default=False)
是否预测特征贡献。
提示::
如果您想使用SHAP值获得有关模型预测的更多解释,
像SHAP互动值一样,
您可以安装shap软件包(https://github.com/slundberg/shap)。
请注意,与shap包不同,使用pred_contrib,我们将返回带有额外内容的矩阵。
列,最后一列是期望值。
**kwargs
Other parameters for the prediction.