简体   繁体   English

在 Jupyter 中运行以下代码时出现错误(numpy.ndarray 对象不可调用)

[英]Getting error (numpy.ndarray' object is not callable) while running following code in Jupyter

Checking Robustness of the model In this section we will check robustness of our LSTM model.检查模型的鲁棒性在本节中,我们将检查 LSTM 模型的鲁棒性。 I have used new unseen datasets for this from July 1, 2017 to July 20,2017.从 2017 年 7 月 1 日到 2017 年 7 月 20 日,我为此使用了新的看不见的数据集。 I have downloaded the data sets from google finance website to check for robustness of the model.我已经从谷歌金融网站下载了数据集来检查模型的稳健性。

import preprocess_data as ppd

data = pd.read_csv('E:/DBSOM DATA\FOM_Sem 2/Analyses of S&U Data/Project work/Stock-Price-Prediction- 
master/googl.csv')

stocks = ppd.remove_data(data)

stocks = ppd.get_normalised_data(stocks)

stocks = stocks.drop(['Item'], axis = 1)
#Print the dataframe head and tail
print(stocks.head())

#X = stocks[:].as_matrix()
#Y = stocks[:]['Close'].as_matrix()
X = stocks[:].values()
Y = stocks[:]['Close'].values()

X = sd.unroll(X,1)
Y = Y[-X.shape[0]:]

print(X.shape)
print(Y.shape)

# Generate predictions 
predictions = model.predict(X)

#get the test score
testScore = model.evaluate(X, Y, verbose=0)
print('Test Score: %.4f MSE (%.4f RMSE)' % (testScore, math.sqrt(testScore)))

The .values property shouldn't have () : .values属性不应该有()

X = stocks[:].values
Y = stocks[:]['Close'].values

Note: the documentation for .values says that .values is no longer recommended, and recommends using .to_numpy() instead.注: 对文件.values.values不再推荐,并建议使用.to_numpy()来代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM