我使用EURUSD OHLC 1天数据做了一个简单的实验。
我的特点是公开价格,低价,高价,我试图预测未来的收盘价。
代码正常工作,正如预期的那样,但结果非常误导。
我得到了99%的准确率,我们都知道这是不可能的。
1)那么我做错了什么呢?
2)如何改正错误?
我正在建设的官方系统将有BoP,购买力平价,利率,国内生产总值,以及许多动量指标,等等,作为功能,超过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 )发布于 2018-07-11 00:25:50
user3666197对这一概念缺陷的讨论恰到好处。
经过广泛的研究,我要证明,利用机器学习的基本模型,即load > transform> fit > predict,使用sklearn或keras甚至tbot自动进行模型参数优化的唯一选择是结合一些未来预测/计算的“某种关系的数据”。
为了给你指明正确的方向,可以尝试以下几点:
此外,更实际的做法是将工作重点放在功能工程和选择上,而不是模型选择上。
祝你好运。
https://stackoverflow.com/questions/41271947
复制相似问题