1# Step 1: Import packages
2import numpy as np
3from sklearn.linear_model import LinearRegression
4from sklearn.preprocessing import PolynomialFeatures
5
6# Step 2a: Provide data
7x = [[0, 1], [5, 1], [15, 2], [25, 5], [35, 11], [45, 15], [55, 34], [60, 35]]
8y = [4, 5, 20, 14, 32, 22, 38, 43]
9x, y = np.array(x), np.array(y)
10
11# Step 2b: Transform input data
12x_ = PolynomialFeatures(degree=2, include_bias=False).fit_transform(x)
13
14# Step 3: Create a model and fit it
15model = LinearRegression().fit(x_, y)
16
17# Step 4: Get results
18r_sq = model.score(x_, y)
19intercept, coefficients = model.intercept_, model.coef_
20
21# Step 5: Predict
22y_pred = model.predict(x_)
23