龙源期刊网
http://www.qikan.com.cn
一种基于
Python
和
BP
神经网络的股票预
测方法
作者:曾武序
钱文彬
王映龙
杨文姬
柳军
来源:《计算机时代》
2018
年第
06
期
摘
要:
股票预测可以辅助投资者进行正确的金融投资,本文使用
Python
语言开发网页爬
虫爬取真实的股票数据,首先通过
requests
库获取网页数据,使用
BeautifulSoup
库解析静态
html
页面,并通过查找标签获取股票数据,然后对数据进行解析,用
xlwt
库将数据存入
excel
文件,并对数据归一化处理,最后,在三层
BP
神经网络中根据批量梯度下降法调整隐含层结
点个数,以获取相对更优的连接权值和阈值,从而对股票的涨跌做出预测,为投资者的投资行
为提供参考。
关键词:
Python
;
网络爬虫;
BP
神经网络;
股票预测
中图分类号:
TP183
文献标志码:
A
文章编号:
1006-8228
(
2018
)
06-72-04
A stock forecasting method based on Python and BP neural network
Zeng Wuxu1
,
Qian Wenbin1
,
Wang Yinglong2
,
Yang Wenji1
,
Liu Jun2
(
1. School of Software
,
Jiangxi Agricultural University
,
Nanchang
,
Jiangxi 330045
,
China
;
2. School of computer and information engineering
,
Jiangxi Agricultural University
)
Abstract
:
Stock predictions can help investors to make the right financial investment. This
article uses Python language to develop web crawlers to crawl real stock data. The web page data is
obtained from the requests library first
,
the static html page is analyzed using the BeautifulSoup
library
,
and the stock data is obtained through searching the tags. Then the data is analyzed
,
the
data is stored in excel file by xlwt library
,
and the data is normalized. Finally
,
the number of
hidden layer nodes is adjusted according to the batch gradient descent method in the three-layer BP
neural network to obtain relatively better connection weights and thresholds
,
so as to predict the ups
and downs of stocks and provide reference for investors' investment behavior.
Key words
:
Python
;
Web crawler
;
BP neural network
;
stock prediction
0
引言