当前位置:网站首页>分享一个因子挖掘的利器:遗传规划
分享一个因子挖掘的利器:遗传规划
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天均值。当前测试品种的单一品种,如何扩展到多品种?这样的三维数据该如何处理?这些都有待解决。
后续将推出进阶版遗传规划,带你进一步探索因子挖掘!
边栏推荐
- 求一个能判断表中数据,只填充不覆盖的sql
- UI自動化測試框架搭建 —— 編寫一個APP自動化
- Matlab exercises -- exercises related to symbolic operation
- Project practice! Teach you JMeter performance test hand in hand
- The development of the Internet has promoted the emergence of a series of new models such as unbounded retail, digital retail and instant retail
- Analysis of distributed transaction TCC
- 10: 00 interview, came out at 10:02, the question is really too
- Aspnetcoreratelimit rate limit interface access limit current limit control
- Notepad++ -- column editing mode -- Usage / instance
- Differences between pragma and ifndef
猜你喜欢

Sword finger offer 53 - I. find the number I in the sorted array (improved bisection)

Annual comprehensive analysis of China's audio market in 2022

Analysis of distributed transaction solution Seata golang

大促场景下,如何做好网关高可用防护

Audio and video technology development weekly

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

Ppt production tips

Taco: a data enhancement technique for character recognition

UI automation test framework construction - write an app automation

TACo:一种关于文字识别的数据增强技术
随机推荐
How do I get the STW (pause) time of a GC (garbage collector)?
Audio and video technology development weekly
Necessary skills for test and development: actual combat of security test vulnerability shooting range
[proteus simulation] timer 1 external counting interrupt
Notepad++ -- common plug-ins
flinkcdc采集oracle,oracle数据库是CDB的
Light collector, Yunnan Baiyao!
Principle of event delegation
华为9年经验的软件测试总监工作感悟—写给还在迷茫的朋友
Precautions for using C language global variables (global variables in C and H files, static global variables)
Array method
!‘cat‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
UI自动化测试框架搭建 —— 编写一个APP自动化
One article explains in detail | those things about growth
Mise en place d'un cadre d'essai d'automatisation de l'interface utilisateur - - rédaction d'une application d'automatisation
Differences between pragma and ifndef
Moonbeam integrates coin98, giving users more choices on the multi chain road
JVM I: introduction to JVM and understanding of class files
TACo:一种关于文字识别的数据增强技术
The development of the Internet has promoted the emergence of a series of new models such as unbounded retail, digital retail and instant retail