多项式Curvefit - ValueError:年份超出范围python

时间:2016-02-02 12:15:15

标签: python time-series curve-fitting polynomials timeserieschart

我有以下代码ValueError: year is out of range python,目的是在时间序列上绘制曲线拟合。

有人可以向我解释为什么我会收到此错误吗?

x_values_formatted=[]

for i in x_values_edited:
    x_values_formatted.append(time.mktime(i.timetuple()))

poly = np.polyfit(x_values_formatted, y_values, 3)

polynomial = np.poly1d(poly)

xs = np.linspace(np.min(x_values_formatted), np.max(x_values_formatted), len(x_values_formatted))

y_int = polynomial(xs)

plt.plot(x_values_edited, y_values, '.')

**plt.plot(xs, y_int)**

plt.show()

数据样本:

所有输入的长度均为1400

x_values_formatted:

[1420088220.0,1420088160.0,1420088100.0,1420088040.0,1420087980.0,1420087920.0,1420087860.0,1420087800.0,1420088340.0,1420088280.0,1420130940.0,1420130880.0,1420130820.0,1420130760.0,1420130700.0 ..

y_values:

[79.5,79.5,80.0,80.25,81.5,81.5,84.25,83.0,79.5,77.0,88.5,89.0,88.0,89.5,88.75,90.0,89.0,89.5,88.5,91.0,85.5,80.5,83.75, 80.25,82.25,80.0,

XS:

[1.42006320e + 09 1.42006326e + 09 1.42006332e + 09 ...,1.42014942e + 09    1.42014948e + 09 1.42014954e + 09]

y_int:

[71.45402408 71.48215866 71.51025748 ...,74.95840454 74.93510818   74.91177654]

x_values_edited

[datetime.datetime(2015,1,1,6,57),datetime.datetime(2015,1,1,6,56),datetime.datetime(2015,1,1,6,55),datetime .datetime(2015,1,1,6,54),datetime.datetime(2015,1,1,6,53),datetime.datetime(2015,1,1,6,52),

0 个答案:

没有答案