Least-squares surfaces with NumPy and SciPy
An appropriate question to ask in this section would be to ask, "Why do we need to fit surfaces to a dataset?" It is important since 2D plots are not enough to show the relationship between the predictor variables (X1, X2, …., Xn) and the predicted variable Y. In many real-life scenarios, Y is affected by more than one X variable, and hence to capture such a relationship, we would need a surface plot (3D), which can show the relationship between X1, X2, and Y. This relationship between the variables can be represented by the following mathematical formulation:
Y βo + β1 X1 + β2 X2
Our goal is to find the values for βo, β1, and β2.
For this section, we will use the horsepower
and weight
values of a car as input for X1 and X2 respectively. The output variable will be displacement (Y). We can mathematically write this as follows:
Y βo + (β1 * horsepower) + (β...