【发布时间】:2017-05-07 10:02:18
【问题描述】:
我使用 EURUSD OHLC 1 天数据做了一个简单的实验。
我的特征是开盘价、低价、高价,我试图预测未来的收盘价。
代码按预期工作,但结果非常具有误导性。
我得到了 99% 的准确度分数,众所周知,这是不可能的。
1) 那我做错了什么?
2) 我怎样才能纠正我的错误?
我正在构建的官方系统将有 BoP、PPI、利率、GDP 和许多 Momentum 指标等作为特征,大约 60 多个特征。
import pandas as pd
import numpy as np
#import matplotlib.pyplot as plt
#import pickle
# 1. Read the EURUSD csv data.
# 2. Process the DataFrame, using only the Open, High, Low, Close columns.
df = pd.read_csv( 'EURUSD1440.csv', index_col= 'Date' )
df = df[['Open','High','Low','Close']]
array = df.values
# Features consist of Open, High, Low column, and stored in x.
# Label is the Close column stored in y.
x = array[:,0:3]
y = array[:,3]
# Split Data into Test and Train.
# 60% Train and 40% Test.
from sklearn.cross_validation import train_test_split
x_train, x_test, y_train, y_test = train_test_split( x, y, test_size = 0.4 )
# 1. Train the Model using .fit method.
# 2. Predict the future Closing prices using the .predict method.
# 3. Know how Accurate the Model is using the .score method.
from sklearn.linear_model import LinearRegression
from sklearn.metrics import accuracy_score
model = LinearRegression()
model.fit( x_train, y_train )
forecast = model.predict( x_test )
accuracy = model.score( x_test, y_test )
print( forecast, accuracy )
【问题讨论】:
-
欢迎来到 StackOverflow。请阅读并遵循帮助文档中的发布指南。 Minimal, complete, verifiable example 适用于此。在您发布代码并准确描述问题之前,我们无法有效地帮助您。尤其要包括您迄今为止所做的数据、输出和调试跟踪。
-
我已经这样做了
-
您可能已经意识到并且想要编辑/更新帖子,因为兼容 MCVE 的帖子也应该是 Complete + V可验证,您尚未为其发布参考
EURUSD1440.csv数据以启用独立重新运行实验。
标签: python-3.x machine-learning time-series quantitative-finance