Linear regression is a good visualization to explain machine learning. The machine or computer actually did not learn by itself to discover the generalized line equation in slope form. In this example you gave the computer six (6) training data points to approximate the best line equation.