#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]:
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()
embedded system,Arduino,Raspberry pi,ARM7,MM32,STM32,PIC and Python,Django,Datascience and web development
Monday, April 6, 2020
polynomial_regression in datascience using python
Sunday, April 5, 2020
linear regression in matplotlib in python
This is the topic related to Linear regression using python
In [4]:
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
page_speeds = np.random.normal(3.0,1.0,1000)
purchase_amount = 100 - (page_speeds + np.random.normal(0,0.1, 1000))*3
plt.scatter(page_speeds,purchase_amount)
Out[4]:
<matplotlib.collections.PathCollection at 0x277ffa83348>
In [5]:
from scipy import stats
slope, intercept, r_value, p_value, std_err = stats.linregress(page_speeds,purchase_amount)
In [6]:
r_value**2
Out[6]:
0.9904525550737715
In [7]:
import matplotlib.pyplot as plt
def predict(x):
return slope * x + intercept
fit_line = predict(page_speeds)
plt.scatter(page_speeds,purchase_amount)
plt.plot(page_speeds,fit_line, c='r')
plt.show()
Subscribe to:
Posts (Atom)
-
using python we can create our on DB using python in mysql. please follow the below lines of code import pymysql #create the database conne...
-
1. Write a program to accept the integer value and print its table. Note: ...