topskill.dev
CoursesTracks
All courses/Machine Learning FundamentalsLinear regression
Supervised prediction algorithms
1 / 10
← Machine Learning Fundamentals
○What machine learning learns○Features and labels○Training and inference○Regression or classification○The machine learning process○Data quality and coverage○Representing data✦Module Quiz
●Linear regression○Try a tiny linear model○Logistic regression○Nearest neighbors○Decision trees○Random forests○Boosting○Naive Bayes○Support vector machines✦Module Quiz
○Clustering○K-means○Choosing and interpreting clusters○Principal component analysis○Neural networks and deep learning○Self-supervised learning○Transfer learning○Reinforcement learning✦Module Quiz
○Generalization and overfitting○Holding out evaluation data○Data leakage○Baselines○Bias and variance intuition○Reading learning curves✦Module Quiz
○Prediction errors and residuals○Measuring regression error○Squared error and large misses○The confusion matrix○Precision and recall○Try a held-out classifier✦Module Quiz
○Bias and limits○Monitoring and drift○Comparing models for a decision✦Module Quiz
Supervised prediction algorithms

Linear regression

For a prediction of duration from distance, linear regression fits a straight-line relationship when there is one numerical feature. Fitting chooses a slope and a starting level that make the observed errors small overall; the line need not pass through every trip.

y^=wx+b\hat{y}=wx+by^​=wx+b

Here y^\hat{y}y^​ (read "y-hat") is predicted time in minutes, xxx is distance in kilometers, www is the added minutes per kilometer, and bbb is the starting number of minutes. The hat marks an estimate rather than an observed answer.

For an illustrative model with w=3w=3w=3 and b=8b=8b=8, a trip of x=4x=4x=4 kilometers gives y^=3×4+8=20\hat{y}=3\times4+8=20y^​=3×4+8=20 minutes. The starting time might reflect pickup work, although the equation alone does not prove that explanation.

With more features, the model adds several weighted contributions. It remains a useful simple comparison model. A straight relationship can miss rush-hour effects, and extending it far beyond the distances seen in training is risky. Prediction is not proof that changing one feature causes the predicted change.

A common fitting objective is the sum of squared differences between observed and predicted targets. The algorithm selects weights to reduce that objective on the training examples. Minimizing training error is not the same as demonstrating useful error on new inputs; the evaluation section separates those questions.

Check your understanding

Must every observed trip sit on the fitted line?

Answer: No. The line summarizes a relationship; individual observations can differ.

Fact 1
1 / 1
FACT 1

No. The line summarizes a relationship; individual observations can differ.