我试图预测我的系列第二天的股价,但我不知道如何“查询”我的模型。这是我在 Python 中的代码:
# Define my period
d1 = datetime.datetime(2016,1,1)
d2 = datetime.datetime(2016,7,1)
# Get the data
df = web.DataReader("GOOG", 'yahoo', d1, d2)
# Calculate some indicators
df['20d_ma'] = pandas.rolling_mean(df['Adj Close'], window=20)
df['50d_ma'] = pandas.rolling_mean(df['Adj Close'], window=50)
# Create the model
from sklearn.linear_model import LinearRegression
from sklearn.cross_validation import train_test_split
X = df[list(df.columns)[6:]] # Adj Close and indicators...
y = df['Adj Close']
X_train, X_test, y_train, y_test = train_test_split(X, y)
model = LinearRegression()
model.fit(X_train,y_train)
好的,我需要查询模型( model.predict(..¿?..) )来预测“下一天”的股价。
我该怎么做?
提前致谢!!!