Python, regression analysis

import numpy as np 
import matplotlib.pyplot as plt 

t = np.arange (1, 10, 1) # Generate a list of time series from 1 to 9 
y = t * 0.9 + np.sin (t) # Generate an upward volatility y-axis Data list 
model = np.polyfit (t, y, deg = 2) #Fit the second-order model. If deg = 1, the first-order linear regression model 
t2 = np.arange (-2, 12, 0.5) # Generate a new time series list 
y2predict = np.polyval (model, t2) #Use the newly generated model model to generate the independent variable y2predict 
plt.plot (t, y, ' under the condition that t2 is the dependent variable o ', t2, y2predict,' x ') 
plt.show ()

  

Guess you like

Origin www.cnblogs.com/iceberg710815/p/12674899.html