Imagine that you just bought an electric car, you have used it to go around in your city but now you are planning to do a long journey to another city. You know that when you use it in your city you do not need to worry much about battery usage because the battery can last for the full day and then in the evening can be recharged. However with a long journey you want to make sure that a fully charged battery is enough to reach the other city so that you do not need to stop to a charging point.
Now, imagine, hypothetically, that you are trying to obtain this information but you cannot find it anywhere so the only thing left to do is to collect data in order to make a prediction on the battery usage. So, you start to go around the city for your normal routine and start collecting the distance travelled and the related battery usage. For example you go from Home to Office in the morning, so by driving for 20Km then the battery usage is 8.5%. Then, after work, you go from the Office to the Supermarket. Again you collect data and in this case the distance travelled is 10Km and the battery usage is 4%. And so on...
Once you reach home you start to look at these initial data and you can find almost a proportional relatioship. So you decide to collect more data over the next days and use a Linear Regression to fit the data. The main goal is then to find the best coefficients of the function which needs to describe the collected data. In this case, the only variable is the distance travelled while the output is the associated battery usage. A full explanation of the problem, the linear regression formulas and the results can be found in the video below from my official Youtube Channel.