lightgbm的sklearn接口和原生接口参数详细说明及调参指点
class lightgbm.LGBMClassifier(boosting_type='gbdt', num_leaves=31, max_depth=-1, learning_rate=0.1, n_estimators=10, max_bin=255, subsample_for_bin=200000, objective=None, min_split_gain=0.0, min_child_weight=0.001, min_child_samples=20, subsample=1.0, subsample_freq=1, colsample_bytree=1.0, reg_alpha=0.0, reg_lambda=0.0, random_state=None, n_jobs=-1, silent=True, **kwargs)
boosting_type |
default="gbdt" |
"gbdt":Gradient Boosting Decision Tree "dart":Dropouts meet Multiple Additive Regression Trees "goss":Gradient-based One-Side Sampling "rf": Random Forest |
|
| num_leaves | (int, optional (default=31)) | 每个基学习器的最大叶子节点 | <=2^max_depth |
| max_depth | (int, optional (default=-1)) | 每个基学习器的最大深度, -1 means no limit | 当模型过拟合,首先降低max_depth |
| learning_rate | (float, optional (default=0.1)) | Boosting learning rate | |
| n_estimators | (int, optional (default=10)) | 基学习器的数量 | |
| max_bin | (int, optional (default=255)) | feature将存入的bin的最大数量,应该是直方图的k值 | |
| subsample_for_bin | (int, optional (default=50000)) | Number of samples for constructing bins | |
| objective | (string, callable or None, optional (default=None)) |
default: ‘regression’ for LGBMRegressor, ‘binary’ or ‘multiclass’ for LGBMClassifier, ‘lambdarank’ for LGBMRanker. |
|
| min_split_gain | (float, optional (default=0.)) | 树的叶子节点上进行进一步划分所需的最小损失减少 | |
| 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)) | 叶子节点具有的最小记录数 | |
| subsample |
(float, optional (default=1.)) | 训练时采样一定比例的数据 | |
| subsample_freq | (int, optional (default=1)) | Frequence 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 or None, optional (default=None)) | ||
| silent | (bool, optional (default=True)) | ||
| n_jobs | (int, optional (default=-1)) |
######################################################################################################
下表对应了Faster Spread,better accuracy,over-fitting三种目的时,可以调整的参数:

###########################################################################################
类的属性:
| n_features_ | int | 特征的数量 |
| classes_ | rray of shape = [n_classes] | 类标签数组(只针对分类问题) |
| n_classes_ | int | 类别数量 (只针对分类问题) |
| best_score_ | dict or None | 最佳拟合模型得分 |
| best_iteration_ | int or None | 如果已经指定了early_stopping_rounds,则拟合模型的最佳迭代次数 |
| objective_ | string or callable | 拟合模型时的具体目标 |
| booster_ | Booster | 这个模型的Booster |
| evals_result_ | dict or None | 如果已经指定了early_stopping_rounds,则评估结果 |
| feature_importances_ | array of shape = [n_features] | 特征的重要性 |
###########################################################################################
类的方法:
fit(X, y, sample_weight=None, init_score=None, eval_set=None, eval_names=None, eval_sample_weight=None, eval_init_score=None, eval_metric='logloss', early_stopping_rounds=None, verbose=True, feature_name='auto', categorical_feature='auto', callbacks=None)
| X | array-like or sparse matrix of shape = [n_samples, n_features] | 特征矩阵 |
| 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)) | 样本权重,可以采用np.where设置 |
| init_score | array-like of shape = [n_samples] or None, optional (default=None)) | Init score of training data |
| group | array-like of shape = [n_samples] or None, optional (default=None) | Group data of training data. |
| eval_set | list or None, optional (default=None) | A list of (X, y) tuple pairs to use as a validation sets for early-stopping |
| eval_names | list of strings or None, optional (default=None) | Names of eval_set |
| eval_sample_weight | list of arrays or None, optional (default=None) | Weights of eval data |
| eval_init_score | list of arrays or None, optional (default=None) | Init score of eval data |
| eval_group | list of arrays or None, optional (default=None) | Group data of eval data |
| eval_metric | string, list of strings, callable or None, optional (default="logloss") | "mae","mse",... |
| early_stopping_rounds | int or None, optional (default=None) | 一定rounds,即停止迭代 |
| verbose | bool, optional (default=True) | |
| feature_name | list of strings or 'auto', optional (default="auto") | If ‘auto’ and data is pandas DataFrame, data columns names are used |
| categorical_feature | list of strings or int, or 'auto', optional (default="auto") | If ‘auto’ and data is pandas DataFrame, pandas categorical columns are used |
| callbacks | list of callback functions or None, optional (default=None) |
###############################################################################################
| X | array-like or sparse matrix of shape = [n_samples, n_features] | Input features matrix |
| raw_score | bool, optional (default=False) | Whether to predict raw scores |
| num_iteration | int, optional (default=0) | Limit number of iterations in the prediction; defaults to 0 (use all trees). |
| Returns | predicted_probability | The predicted probability for each class for each sample. |
| Return type | array-like of shape = [n_samples, n_classes] |
不平衡处理的参数:
1.一个简单的方法是设置is_unbalance参数为True或者设置scale_pos_weight,二者只能选一个。 设置is_unbalance参数为True时会把负样本的权重设为:正样本数/负样本数。这个参数只能用于二分类。
2.自定义评价函数:
https://cloud.tencent.com/developer/article/1357671
lightGBM的原理总结:
http://www.cnblogs.com/gczr/p/9024730.html
论文翻译:https://blog.csdn.net/u010242233/article/details/79769950,https://zhuanlan.zhihu.com/p/42939089
处理分类变量的原理:https://blog.csdn.net/anshuai_aw1/article/details/83275299
CatBoost、LightGBM、XGBoost的对比
https://blog.csdn.net/LrS62520kV/article/details/79620615
lightgbm的sklearn接口和原生接口参数详细说明及调参指点的更多相关文章
- xgboost的sklearn接口和原生接口参数详细说明及调参指点
from xgboost import XGBClassifier XGBClassifier(max_depth=3,learning_rate=0.1,n_estimators=100,silen ...
- word2vec参数调整 及lda调参
一.word2vec调参 ./word2vec -train resultbig.txt -output vectors.bin -cbow 0 -size 200 -window 5 -neg ...
- DeepMind提出新型超参数最优化方法:性能超越手动调参和贝叶斯优化
DeepMind提出新型超参数最优化方法:性能超越手动调参和贝叶斯优化 2017年11月29日 06:40:37 机器之心V 阅读数 2183 版权声明:本文为博主原创文章,遵循CC 4.0 BY ...
- python+pytest接口自动化(6)-请求参数格式的确定
我们在做接口测试之前,先需要根据接口文档或抓包接口数据,搞清楚被测接口的详细内容,其中就包含请求参数的编码格式,从而使用对应的参数格式发送请求.例如某个接口规定的请求主体的编码方式为 applicat ...
- android 学习随笔二十七(JNI:Java Native Interface,JAVA原生接口 )
JNI(Java Native Interface,JAVA原生接口) 使用JNI可以使Java代码和其他语言写的代码(如C/C++代码)进行交互. 问:为什么要进行交互? 首先,Java语言提供的类 ...
- 接口作为方法的参数或返回值——List接口
接口作为方法的参数或返回值,源码可知,List为一个接口,ArraryList是的它的实现类: 其中,addNames方法中,入参和返回值都List接口,入参是多态的,编译看左,运行看右(访问成员方法 ...
- 编写高质量代码改善C#程序的157个建议——建议43:让接口中的泛型参数支持协变
建议43:让接口中的泛型参数支持协变 除了上一建议中提到的使用泛型参数兼容接口不可变性外,还有一种办法是为接口中的泛型声明加上out关键字来支持协变,如下所示: interface ISalary&l ...
- Python+request 分模块存放接口,多接口共用参数URL、headers的抽离,添加日志打印等《三》
主要介绍内容如下: 1.分模块存放接口 2.多接口共用参数URL.headers的抽离为配置文件 3.添加日志打印 4.一个py文件运行所有所测的接口 如上介绍内容的作用: 1.分模块存放接口:方便多 ...
- 对接接口时,组织参数json出现的问题
在进行对接第三方接口时,进行参数组装成json的过程中出现参数传递格式错误以及json格式化错误. 在拼接json时,如果json中有对象,则以map的方式组装好所有参数.最后map转成json,不然 ...
随机推荐
- lapis 1.7.0 更好的openresty 版本兼容以及安全数据库支持
lapis 1.7.0 今年4月2号就发布了,一直没有注意,今天看到changelog就简单的进行了一个 测试(主要是与openresty版本的测试,新变更后边会有) 使用docker-compose ...
- oracle-scn
在2012年第一季度的CPU补丁中,包含了一个关于SCN修正的重要变更,这个补丁提示,在异常情况下,Oracle的SCN可能出现异常增长,使得数据库的一切事务停止,由于SCN不能后退,所以数据库必须重 ...
- JDK8中的时间API
在Java 1.0中,对日期和时间的支持只能依赖java.util.Date类.正如类名所表达的,这个类无法表示日期,只能以毫秒的精度表示时间.更糟糕的是它的易用性,由于某些原因未知的设计决策,这个类 ...
- Redis Cluster 4.0高可用集群安装、在线迁移操作记录
之前介绍了redis cluster的结构及高可用集群部署过程,今天这里简单说下redis集群的迁移.由于之前的redis cluster集群环境部署的服务器性能有限,需要迁移到高配置的服务器上.考虑 ...
- dva 知识点
dva中,路由模式从hashHistory换成 browserHistory: dva-cli创建的项目中,src/index.js相应部分修改如下: import browserHistory fr ...
- git push文件到远程github或者gitlab
Git global setup git config --global user.name "luozeng" git config --global user.email &q ...
- spring-IOC容器(二)
一.bean配置里面使用外部属性文件: <bean>中添加context Schema定义,Spring 提供了一个<property-placeholder>元素,可以在be ...
- Ribbon 负载均衡机制
Ribbon 提供了几个负载均衡的组件,其目的就是让请求转给合适的服务器处理,因此,如何选择合适的服务器变成了负载均衡机制的核心,Ribbon 提供了如下负载均衡规则: RoundRobinRule: ...
- Spring Boot 监控与管理
在微服务架构中,我们将原本庞大的单体系统拆分为多个提供不同服务的应用,虽然,各个应用的内部逻辑因分解而简化,但由于部署的应用数量成倍增长,使得系统的维护复杂度大大提升,为了让运维系统能够获取各个为服务 ...
- SPI 核软件调试记录
SPI 核软件调试记录 1.首先说说int SpiFlashWaitForFlashReady(void)这一函数,基本上其它函数在执行的时候,都会事先执行一次此函数. 因为此函数的作用主要是用 ...