本文主要是介绍python股票分析程序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import pandas as pd
import numpy as np
#input
stock = pd.read_csv('C:/Users/华硕/Desktop/沪深A股2020020.csv',encoding='GBK')
stock=stock.replace('-- ','0')
stock=stock.fillna('0')
print(stock)#y
y = stock['涨幅%']
print(y.shape)#X
features = stock.loc[:,'现价':'量比']
X = features.values
print(X.shape)#MLP
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import RobustScaler
from sklearn.neural_network import MLPRegressor
mlpr=MLPRegressor(random_state=62, hidden_layer_sizes=(100,100),alpha=0.001)
X_train, X_test, y_train, y_test=train_test_split(X,y,random_state=62)
scaler = RobustScaler()
scaler.fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)
mlpr.fit(X_train_scaled, y_train)
print('模型准确率&#x
这篇关于python股票分析程序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!