Monday, April 6, 2020

polynomial_regression in datascience using python

#polynomial regression
In [7]:
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(2)
page_speeds = np.random.normal(3.0,1.0,1000)
purchase_amount = np.random.normal(50.0,10.0,1000)/page_speeds

plt.scatter(page_speeds,purchase_amount)
Out[7]:
<matplotlib.collections.PathCollection at 0x1f82b374588>
In [13]:
x= np.array(page_speeds)
y = np.array(purchase_amount)

p4 = np.poly1d(np.polyfit(x,y,3))
In [14]:
xp = np.linspace(0,7,100)
plt.scatter(x,y)
plt.plot(xp,p4(xp), c='r')
plt.show()
In [ ]:
xp = np.linspace(0,7,100)
plt.scatter(x,y)
plt.plot(xp,p4(xp), c='r')
plt.show()

python class topic video