python
1import pandas as pd 2import numpy as np 3from sklearn.model_selection import train_test_split 4from sklearn.linear_model import LinearRegression as lr 5from sklearn.linear_model import Lasso 6from sklearn.metrics import mean_squared_error as mse 7from sklearn.metrics import mean_absolute_error as mae 8from sklearn.preprocessing import MinMaxScaler 9from sklearn.metrics import mean_squared_error 10from sklearn.metrics import r2_score 11from statsmodels.tsa.ar_model import AR 12import statsmodels.api as sm 13import statsmodels.formula.api as smf 14from matplotlib import pyplot as plt 15%matplotlib inline 16 17data = pd.read_csv('./data/ALT1334.csv') 18data_ = data.iloc[:,1:199].T 19 20X_train, y_train, X_test, y_test = data_.iloc[94:193], data_.iloc[193:196], data_.iloc[95:194], data_.iloc[194:197] 21 22model = sm.OLS(y_train.T.values, X_train.T.values) 23result = model.fit() 24train_pred = result.predict(X_train.T.values) 25test_pred = result.predict(X_test.T.values) 26 27np.dot(X_test.T, result.params), test_pred 28 29plt.plot(y_test.T.values) 30plt.plot(test_pred.T.values)
以上のようなコードを入力すると、下から2行目のplt.~で
'numpy.ndarray' object has no attribute 'values'
といったエラーが出てしまい、プロット図が表示されません。
解決方法を教えていただけると幸いです。
回答2件
あなたの回答
tips
プレビュー