Polyfit performs polynomial regression.
import numpy as np
import matplotlib.pyplot as plt
x = np.array([-1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1])
y = np.array([ 2, 1.8, 1.7, 1.6, 1.8, 2, 2.2, 2.1, 2.0, 2.3, 2.4])
d = 2 # Set polynomial degree
w = np.polyfit(x, y, d) # Coefficients of regression equation
fx = np.poly1d(w)(x) # Calculate the value of a polynomial
print(w)
plt.scatter(x, y)
plt.plot(x, fx)
plt.show()