当前位置:网站首页>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
边栏推荐
猜你喜欢
Carefully organize 16 MySQL usage specifications to reduce problems by 80% and recommend sharing with the team
自动化机器学习pycaret: PyCaret Basic Auto Classification LightGBM
SVN服务器搭建+SVN客户端+TeamCity集成环境搭建+VS2019开发
Interview assault 69: TCP reliable?Why is that?
【Acwing】The 62nd Weekly Game Solution
SVN server construction + SVN client + TeamCity integrated environment construction + VS2019 development
如何设计高可用高性能中间件 - 作业
类和对象:上
【读书笔记->数据分析】02 数据分析准备
Mysql environment installation under Linux (centos)
随机推荐
thymeleaf迭代map集合
SQL注入 Less54(限制次数的SQL注入+union注入)
Difference between first and take(1) operators in NgRx
vim的基本使用-底行模式
面试突击69:TCP 可靠吗?为什么?
类和对象:上
How to reduce the gap between software design and implementation
Named Entity Recognition - Model: BERT-MRC
输入输出优化
Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)
/etc/sysconfig/network-scripts configure the network card
面试题:实现死锁
IPD process terminology
cobaltstrike
【读书笔记->数据分析】02 数据分析准备
Xinao Learning Plan The Road to Informatics Competition (2022.07.31)
22年8月推广大使额外奖励规则
UOS统信系统 - WindTerm使用
Google Earth Engine——Error: Image.clipToBoundsAndScale, argument ‘input‘: Invalid type的错误解决
UOS - WindTerm use