尝试线性回归但重塑误差

时间:2017-06-04 17:29:03

标签: python python-2.7 python-3.x ipython-notebook

我正在尝试进行线性回归,但我收到了这个错误:

ValueError: cannot reshape array of size 2246 into shape (2,2246)

C:\Users\Brian\Anaconda3\lib\site-packages\ipykernel_launcher.py:2: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead

这是我的代码。

import pandas as pd
import matplotlib.pyplot as plt
% matplotlib inline
df = pd.read_csv(r'C:\Users\Brian\Desktop\GOOGTICKER.CSV')
df
times = pd.DatetimeIndex(df['Date'])
grouped= df.groupby([times.year]).mean()
from sklearn import linear_model
x_val= times
y_val= df['GOOGL']
body_reg =linear_model.LinearRegression()
body_reg.fit(x_val, y_val)

我已将numpy导入为py并尝试重塑,但我仍然收到错误。任何建议将不胜感激。谢谢你的时间。

0 个答案:

没有答案