Linear regression: Parameters exercise

The graph below plots 20 examples from a fuel-efficiency dataset, with thefeature (car heaviness in thousands of pounds) plotted on the x-axis and thelabel (miles per gallon) plotted on the y-axis.

Your task: Adjust theWeight andBias sliders above the graph tofind the linear model that minimizes MSE loss on the data.

Questions to consider:

  • What is the lowest MSE you can achieve?
  • What weight and bias values produced this loss?

Click the plus icon to see the solution

The optimal linear model for this data has an MSE of 3.37, with a weight of –0.12 and a bias of 16.96, as shown in the following image.

Plot of 20 points and the optimal linear regression line for              these points, using the weight and bias values above.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-27 UTC.