问题描述
我正在制作LSTM模型,并正在kaggle上找到的TSLA数据集上对其进行训练。所以我的问题是,当我调用model.predict时,这种预测会给我第二天的股票价格吗?这是一个一步的预测吗?当我打印model.predict时,我得到了一个很大的列表,所以我使用numpy argmax函数给我一个数字。这是代码:
function Application() {
const user = useContext(UserContext);
return user ? (
<Router>
<ProfilePage path={`/user/${user.uid}`} authenticatedUser={user} exact />
<NotFound default />
</Router>
) : (
<Router>
<SignIn path="/" />
<SignUp path="signUp" />
<PasswordReset path="passwordReset" />
</Router>
);
}
解决方法
Argmax在这里没有意义。 90个值是训练集第二天的90个预测。运行此命令时:
preds = model.predict(X)
它为您的火车集合的所有90个数据点提供第二天的值。这行:
print(np.argmax(outs))
毫无意义。
顺便说一句,您可以使用Python获取股价,不需要CSV。
pip install pandas-datareader
from pandas_datareader import data as wb
ticker=wb.DataReader('TSLA',start='2015-1-1',data_source='yahoo')
print(ticker)
High Low ... Volume Adj Close
Date ...
2015-01-02 44.650002 42.652000 ... 23822000.0 43.862000
2015-01-05 43.299999 41.431999 ... 26842500.0 42.018002
2015-01-06 42.840000 40.841999 ... 31309500.0 42.256001
2015-01-07 42.956001 41.956001 ... 14842000.0 42.189999
2015-01-08 42.759998 42.001999 ... 17212500.0 42.124001
... ... ... ... ...
2020-10-13 448.890015 436.600006 ... 34463700.0 446.649994
2020-10-14 465.899994 447.350006 ... 48045400.0 461.299988
2020-10-15 456.570007 442.500000 ... 35672400.0 448.880005
2020-10-16 455.950012 438.850006 ... 32620000.0 439.670013
2020-10-19 447.000000 437.649994 ... 9422697.0 442.840607