0
x = [2017-06-07 00:00:00, 2017-07-19 00:00:00]
y = [155.98, 151.42]

I am finding it difficult finding the slope and y-intercept due to the x axis as timestamp. So I dumped the code( I was using np.polyfit()) I was using before. As it was getting more and more complex. I want a more simple way to do it. Here's my old code:

coefficients =np.polyfit(x, y, 1)
polynomial = np.poly1d(coefficients)
x_axis = np.linspace(2017-06-07 00:00:00, 2017-07-19 00:00:00, 3)  # linspace(start, end, num)
y_axis = polynomial(x_axis)
Predicted_Value = y_axis[2]
plt.plot(x_axis, y_axis)
plt.plot(x[0], y[0], 'go')
plt.plot(x[1], y[1], 'go')
plt.show()

This code has lots of errors, this code is just for reference on the method am using to draw a line. which i dont want to use anymore.

Any help will be greatly appreciated.

0 Answers0