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算法交易
166
|
第
5
章
scikit-learn
在以统一的方式提供对各种机器学习模型的访问方面做得
很好。这些示例表明,用于逻辑回归的
API
与用于线性回归的
API
没有
区别。因此,
scikit-learn
非常适合在特定应用程序场景中测试许多适
当的机器学习模型,而无需太多更改
Python
代码。
配备了基础知识之后,下一步就是将逻辑回归应用于预测市场方向的问题。
5.2.3
使用逻辑回归预测市场方向
在机器学习中,人们通常说特征,而不是像回归语境中的自变量或解释变量。简单
分类示例仅具有一个特征:学习的小时数。在实践中,一个对象常常具有不止一种
可用于分类的特征。在本章介绍的预测方法下,可以通过滞后识别特征。因此,使
用时间序列数据中的三个滞后意味着存在三个特征。作为可能的结果或类别,向上
和向下移动分别只有
+1
和
-1
。
尽管措辞有所变化,但形式上保持不变,尤其是在
推导矩阵(现在称为特征矩阵)方面。
以下代码为创建基于
pandas
的
DataFrame
的“特征矩阵”提供了一种替代方法,如
果不采用
Python
方式,则三步过程同样适用。现在,特征矩阵是原始数据集中各列
的子集:
In [89]: symbol = 'GLD'
In [90]: data = pd.DataFrame(raw[symbol])
In [91]: data.rename(columns={symbol: 'price'}, inplace=True)
In [92]: data['return'] = np.log(data['price'] ...
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