r/MLQuestions • u/[deleted] • Oct 17 '18
Isn't "Linear Regression" the exact same thing as the "line of best fit" that we all learned in 6th grad math? How is it any more complicated than that?
When I first heard about "linear regression" I was scared and thought wow that's some complex genius stuff that must be way over my head. Then when I saw what linear regression actually computes, I just thought "wait a minute...isn't this just a line of best fit? I learned that in the 6th grade!" So, wtf? It's just a computation of a line of best fit through a scatter plot? Middle school children know that concept ffs. How is this touted as such a complex and powerful machine learning tool? A 12 year old could do that for you by drawing a line through a scatter plot like he did on his math test last week!
And besides, there is a function to calculate the line of best fit built into matplotlib. So if I have that, why can't I just make a scatter plot with my data in matplotlib, then call the line of best fit function on that plot? Why do I even need to build a complex linear regression calculation if all it is is a line of best fit, which I can easily get the equation of by just calling a matplotlib function?
3
u/atzenkatzen Oct 17 '18
The line of best fit that you learned in elementary school is a very simple case of linear regression. You were confined to 2 dimensions and a small amount of clean, linear data. Linear regression can deal with data in an arbitrary number of dimensions. Also, most of the work that goes into building linear models is cleaning up and experimenting with transformations on the data so that it can fit nicely into the model. Thats something that you wouldn't have done in elementary school. But you're correct that it isn't very complicated and thats part of what makes it a powerful and useful tool.
2
Oct 17 '18
There’s a line of best fit function in matplotlob? Are you sure? If so please link it to me as I’d like to see it. If it does exist, I’d bet my shoes it would use linear regression or a variant under the hood.
Anyway sure a 12 year old can draw a line of best fit. Can they draw a plane of best fit in and 3d volume? What about an n dimensional hyperplane in n+1 dimensions? Nope.
We need tools like this to quantify what exactly we mean by ‘best fit’. Funnily enough linear regression was discovered even before the normal distribution, and the distribution was discovered in relation to linear regression.
I don’t know where you have heard that it is a very powerful or complicated technique. By modern standards it’s ludicrously simple. But it’s still practically useful and theoretically and historically important.
Why does it bother you than linear regression is simple? Are you worried that’s all there is?
1
u/chrisbot5000 Oct 18 '18
The most elegant tools seem obvious. A Phillips head screwdriver is obvious once you see it, but it takes a bit of brilliance to invent it in the first place.
10
u/semimetaphorical Oct 17 '18
I'm a bit shocked that you've heard of linear regression as {"complex genius stuff", "complex and powerful machine learning tool"}, giving you the benefit of the doubt I'll just say it sucks that it was so mystified in your experience.
Linear Regression is a very powerful tool when used correctly for machine learning. It might seem trivial when you're looking at a 2 or 3-dimensional plot, but I don't know any 12-year olds who could give you the line of best fit when your samples have 10+ features.
The regression is not useful just for the pretty line it makes, but because you can analyze its coefficients to identify important or redundant features, or decide which is the best model out of a group. This is not entirely straightforward.
One thing worth noting is that linear regression is only a "line of best fit" with a very specific definition: It is built on the scaling of X (plus a bias) that most reduces the error when predicting y.
In other words, a classic linear regression in two-axes is directional: if you computed it using weight>height and height>weight you might get different lines. When 12-year olds draw lines, they are probably minimizing the distance between each point and the closest point on the "best fit" line, which is a specific type of regression. There's discussion all over the internet on this, which might interest you further.