当前位置:网站首页>分享一个因子挖掘的利器:遗传规划
分享一个因子挖掘的利器:遗传规划
2022-06-28 04:27:00 【量化密码库】
你是如何挖掘因子的呢?基于经验吗?但经验是有限的,总会有用尽的时候。基于研报或者论文等公开资料?但这类因子不可避免地涉及到因子拥挤问题,毕竟有效的因子,其他人也会用。
那么还有其他方法吗?答案是有。
今天我们便基于华泰证券的《人工智能系列之基于遗传规划的选股因子挖掘》,给大家介绍一款因子挖掘的利器: 遗传规划 。
什么是遗传规划?
遗传规划是演化算法的分支,是一种启发式的公式演化技术。它从随机生成的公式群体开始。通过模拟自然界中遗传进化的过程,来逐渐生成契合特定目标的公式群体。作为一种监督学习方法,遗传规划可以根据特定目标,发现某些隐藏的、难以通过人脑构建出的数学公式。传统的监督学习算法主要运用于特征与标签之间关系的拟合,而遗传规划则更多运用于特征挖掘(特征工程)。
——《人工智能系列分析报告之基于遗传规划的选股因子挖掘》
以往的因子研究都是“先有逻辑,后有公式”,是一种“演绎法”。但遗传规划的形式是“先有公式,后有逻辑”,属于“归纳法”。它的优势在于可以充分利用计算机的强大算力进行启发式搜索,同时突破人类的思维局限,挖掘出某些隐藏的、难以通过人脑构建的因子,为因子研究提供更多的可能性。
生物中的遗传进化会涉及到基因的遗传,变异,对生态环境的适应能力等情况,遗传规划算法中也是如此,也会有交叉变异、子树变异、点变异、Hoist变异和适应度等,具体细节可以查看研报或论文。
我们采用Python遗传规划项目中的gplearn模块包进行因子挖掘,模型的主要参数如下:

模型所要用到的数据如下:
- 测试品种:上证指数
- 回测区间:2010年01月01日-2022年05月31日
- 初始因子:开盘价、收盘价、最高价、最低价、成交量、收益率、成交量加权平均价
- 预测目标:未来5天收益率
- 函数列表:所有gplearn自带函数
准备好数据之后就可以开始训练模型了:
gp1 = SymbolicTransformer(generations=10, population_size=1000, function_set=function_set, init_depth=(1,4), tournament_size=20, metric='spearman', p_crossover=0.4,
p_subtree_mutation=0.01, p_hoist_mutation=0, p_point_mutation=0.01, p_point_replace=0.40,
warm_start=False, verbose=1,random_state=0, n_jobs=-1,feature_names=['open', 'close', 'high', 'low', 'volume', 'return_rate', 'vwap'])
...
gp1.fit(train,label)# 训练模型
模型会自动显示过程日志,其中Fitness是适应度,这里我们选用的是Spearman秩相关系数,相关系数越高,代表因子与未来5天收益率相关度越高 。

我们进一步通过曲线的形式展示最优因子的迭代过程:

由上图可以看出,最优因子大约迭代到第四代(X轴中,0是第一代)的时候,秩相关系数就达到了较高水平,后续的迭代提升并不高。
最后通过树形图来看下模型迭代出来的最优因子:

用公式来表达便是:log(收盘价)/log(成交量) 。结合下模型前十个最优因子:

可以发现,模型的输出结果中有很多重复的因子,剔除重复因子后,只有两个因子分别为:log(收盘价)/log(成交量)和log(成交量)/log(收盘价) 。
其实这两个因子应该算同一个因子,只是进行了倒数变形。以log(收盘价)/log(成交量)因子来看,先分别对收盘价和成交量进行对数计算,再相除,可以看作是以成交量倒数加权下的收盘价。感兴趣的朋友,可以进一步测试该因子的表现,也可以对其他指数或商品期货进行因子挖掘。
本篇内容是对遗传规划的前期探索,但其中还有很大一块内容是还没有解决的,比如本次所用到的函数都是gplearn自带函数。如何扩充函数?尤其是时间序列型的函数,例如求历史5天均值。当前测试品种的单一品种,如何扩展到多品种?这样的三维数据该如何处理?这些都有待解决。
后续将推出进阶版遗传规划,带你进一步探索因子挖掘!
边栏推荐
- PHP code wechat, official account and enterprise wechat send emoticons [u+1f449]
- 恭喜我自己,公众号粉丝破万
- [csp-j2020] excellent splitting
- 多线程实现 重写run(),怎么注入使用mapper文件操作数据库
- How to clean the nozzle of Epson l3153 printer
- Recommended by Alibaba P8, Fiddler packet capturing tool (I)
- JVM I: introduction to JVM and understanding of class files
- Why are cloud vendors targeting this KPI?
- Aspnetcoreratelimit rate limit interface access limit current limit control
- On the necessity of building a video surveillance convergence platform and its scenario application
猜你喜欢

100+ data science interview questions and answers Summary - machine learning and deep learning

On the necessity of building a video surveillance convergence platform and its scenario application

Function and working principle of controller

CI & CD must be known!
![[matlab traffic light identification] traffic light identification [including GUI source code 1908]](/img/0e/3103c4c5dd664196c85db9b30bcaf5.png)
[matlab traffic light identification] traffic light identification [including GUI source code 1908]

Mise en place d'un cadre d'essai d'automatisation de l'interface utilisateur - - rédaction d'une application d'automatisation

Audio and video technology development weekly

!‘cat‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

Detailed reading of the thesis: implementing volume models for handowriting text recognition

MySQL gets the current date of the year
随机推荐
10: 00 interview, came out at 10:02, the question is really too
求一个能判断表中数据,只填充不覆盖的sql
Pager when importing text files from MySQL
Difference between curdate() and now()
为什么大厂不让使用undefined
UI自動化測試框架搭建 —— 編寫一個APP自動化
Principle of event delegation
【Matlab红绿灯识别】红绿灯识别【含GUI源码 1908期】
Notepad++ -- column editing mode -- Usage / instance
Severe tire damage: the first rock band in the world to broadcast live on the Internet
Meta universe standard forum established
native关键字的作用
【微服务|OpenFeign】OpenFeign快速入门|基于Feign的服务调用
To quickly download JDK, in addition to the official Oracle download, is there a download address for the latest version available in China
[CSP-J2020] 优秀的拆分
Find an SQL that can judge the data in the table and only fill in the SQL that is not overwritten
2022年安全员-A证考试题库及模拟考试
Matlab exercises -- routine operation of matrix
Sword finger offer 49 Ugly number (three finger needling technique)
Function and working principle of controller