当前位置:网站首页>Qlib quantitative source analysis: qlib/qlib/contrib/model/GBDT py
Qlib quantitative source analysis: qlib/qlib/contrib/model/GBDT py
2022-08-01 00:02:00 【Artificial Intelligence Zeng Xiaojian】
qlib gbd (lightgbm) uses an interface very similar to sklearn, and dataset.prepare returns the training set and test set.
Look at the code of the GBDT module, it first calls _prepare_data, using the data set dataset.prepare function, get two parts of train and valid, and then perform basic data inspection and transformation to fit the model.
def _prepare_data(self, dataset: DatasetH, reweighter=None) -> List[Tuple[lgb.Dataset, str]]:"""The motivation of current version is to make validation optional- train segment is necessary;"""ds_l = []assert "train" in dataset.segmentsfor key in ["train", "valid"]:if key in dataset.segments:df = dataset.prepare(key, col_set=["feature", "label"], data_key=DataHandlerLP.DK_L)if df.empty:raise ValueError("Empty data from dataset, please check your dataset config.")x, y = df["feature"], df["label"]# Lightgbm need 1D array as its labelif y.values.ndim == 2 and y.values.shape[1] == 1:y = np.squeeze(y.values)else:raise ValueError("LightGBM doesn't support multi-label training")if reweighter is None:w = Noneelif isinstance(reweighter, Reweighter):w = reweighter.reweight(df)else:raise ValueError("Unsupported reweighter type.")ds_l.append((lgb.Dataset(x.values, label=y, weight=w), key))return ds_l边栏推荐
猜你喜欢
随机推荐
pycaret源码分析:下载数据集\Lib\site-packages\pycaret\datasets.py
EntityFramework保存到SQLServer 小数精度丢失
【读书笔记->数据分析】02 数据分析准备
【Acwing】The 62nd Weekly Game Solution
SQL injection Less47 (error injection) and Less49 (time blind injection)
When can I use PushGateway
vim的基本使用概念
The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
[Reading Notes -> Data Analysis] 02 Data Analysis Preparation
Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)
一行代码解决CoreData托管对象属性变更在SwiftUI中无动画效果的问题
Shell common script: Nexus batch upload local warehouse script
编译型语言和解释型语言的区别
如何导入 Golang 外部包并使用它?
One line of code to solve CoreData managed object properties change in SwiftUI problem of animation effects
新产品如何进行网络推广?
date命令
面试题:实现死锁
虹科分享|如何用移动目标防御技术防范未知因素
编写方法将一个数组扁平化并且去重和递增排序






![[AMEX] LGBM Optuna美国运通信用卡欺诈赛 kaggle](/img/64/55af53a3d9dc1162490d613fe8a436.png)

