Skip to Content
Python算法交易
book

Python算法交易

by Yves Hilpisch
November 2022
Intermediate to advanced
392 pages
10h 8m
Chinese
China Electric Power Press Ltd.
Content preview from Python算法交易
通过机器学习预测市场动向
|
159
图 5-8:GDX ETF 的总表现和基于回归的策略(七个滞后,样本外,扣除交易成本后)
5.2
使用机器学习进行市场动向预测
如今,
Python
生态系统在机器学习领域提供了许多软件包。其中最流行的是
scikit-learn
[
请参见
scikit-learn
主页(
http://scikit-learn.org
)
]
,它也是记录最
完整和维护最完善的软件包之一。本部分首先介绍基于线性回归的程序包的
API
,
跟上一部分的结果一样。然后,继续使用逻辑回归作为分类算法来解决预测未来市
场方向的问题。
5.2.1 scikit-learn
的线性回归
为了介绍
scikit-learn
API
,重新介绍本章介绍的预测方法背后的基本思想是富有
成效的。数据准备与仅使用
NumPy
相同:
In [61]: x = np.arange(12)
In [62]: x
Out[62]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
In [63]: lags = 3
160
|
第
5
章
In [64]: m = np.zeros((lags + 1, len(x) - lags))
In [65]: m[lags] = x[lags:]
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
图解大模型 : 生成式AI 原理与实战

图解大模型 : 生成式AI 原理与实战

Jay Alammar, Maarten Grootendorst

Publisher Resources

ISBN: 9787519869694