Foundations of Machine LearningRegressionFoundations of Machine LearningRegressionSimple linear regression (简单线性回归)Evaluating the modelMultiple linear regression (多元线性回归)Polynomial regression (多项式回归)Regularization (正则化)Applying linear regressionFitting models with gradient descent (梯度下降)Linear RegressionLesson 3 - 2Simple linear regressionSimple linear regression can be used to model a linear relationship between one response variable and one explanatory variable. Suppose you wish to know the price of a pizza.Linear RegressionLesson 3 - 3Observe the dataLinear RegressionLesson 3 - 4import matplotlib.pyplot as pltX = [[6], [8], [10], [14], [18]]y = [[7], [9], [13], [17.5], [18]]plt.figure()plt.title('Pizza price plotted against diameter')plt.xlabel('Diameter in inches')plt.ylabel('Price in dollars')plt.plot(X, y, 'k.')plt.axis([0, 25, 0, 25])plt.grid(True)plt.show()Sklearn.linear_model.LinearRegressionLinear RegressionLesson 3 - 5# import sklearnfrom sklearn.linear_model import LinearRegression# Training dataX = [[6], [8], [10], [14], [18]]y = [[7], [9], [13], [17.5], [18]]# Create and fit the modelmodel = LinearRegression()model.fit(X, y)print('A 12" pizza should cost: $%.2f' % model.predict([12])[0])# A 12" pizza should cost: $13.68Sklearn.linear_model.LinearRegressionThe sklearn.linear_model.LinearRegression class is an estimator. Estimators predict a value based on the observed data. In scikit-learn, all estimators implement the fit() and predict() methods. The former method is used to learn the parameters of a model, and the latter method is used to predict the value of a response variable for an explanatory variable using the learned parameters. It is easy to experiment with different models using scikit-learn because ...