1poly = PolynomialFeatures(degree=2)
2X_F1_poly = poly.fit_transform(X_F1)
3
4X_train, X_test, y_train, y_test = train_test_split(X_F1_poly, y_F1,
5 random_state = 0)
6linreg = LinearRegression().fit(X_train, y_train)
7
1import numpy as np
2import matplotlib.pyplot as plt
3
4x = [1,2,3,5,6,7,8,9,10,12,13,14,15,16,18,19,21,22]
5y = [100,90,80,60,60,55,60,65,70,70,75,76,78,79,90,99,99,100]
6
7#a method that lets us make a polynomial model:
8model = np.poly1d(np.polyfit(x,y,3))
9
10#Then specify how the line will display, we start
11#at position 1, and end at position 22
12line = np.linspace(1, 22, 100)
13
14
15plt.scatter(x, y)
16plt.plot(line, model(line))
17plt.show()