Algorithms 2—Linear Regression
摘要
This chapter starts with defining a simple linear regression method with one variable using Python. Then, it focuses on linear regression with multiple variables. We first show how to obtain the least squares estimation via SymPy. Next, we define a generic function for linear regression with multiple variables. Furthermore, we demonstrate how to call for the linear regression method from scikit-learn in two ways: LinearRegression, which provides the ordinary least squares linear regression method, and SGDRegressor, which fits a linear model with the stochastic gradient descent algorithm on either the entire training dataset or a portion of it.