A4.3.1Linear regression for predicting continuous outcomes
0/9
A4.3 Machine learning approachesA4.3.1

Linear regression for predicting continuous outcomes

Explain how linear regression is used to predict continuous outcomes

AHL≈ 55 minCommand term: ExplainFree lesson

In this lesson

  • Explaining the relationship between the independent (predictor) and dependent (response) variables
  • Explaining the significance of the slope and the intercept in the regression equation
  • Explaining how well a model fits the data, using r²

LearnPredicting a number

    0 of 5

    LearnSlope and intercept

      0 of 4

      LearnFinding the line, and measuring the fit

        0 of 5

        LabFit a line

        Move the line yourself, then compare it with the least-squares line. Watch the residuals, SSres, SStot and r², and try the data sets where a straight line works badly.

        0510152025015304560Distance (km)Fare (€)mean

        Fare = 28.40 + 0.000 × Distance

        SSres = 3,473 · SStot = 3,473 · r² = 1 − SSres ÷ SStot = 0.000

        A flat line at the mean of the data: SS_res equals SS_tot, so r² is about 0. The line explains none of the variation.

        Move the sliders yourself, fit the least-squares line on at least three data sets, and make a prediction to complete this activity.

        CheckQuick check

        A model predicts a phone's battery life in hours from the hours of video watched per day: battery life = 31.0 − 2.4 × video hours. What does −2.4 tell you?

        CheckQuick check

        A regression model of a gym's daily visitors has SSres = 300 and SStot = 1200. What is r²?

        CheckRegression or classification?

        Is each outcome continuous (a regression problem) or a category (a classification problem)?

        1. The number of minutes a delivery will take
        2. Whether a bank transaction is fraudulent
        3. Tomorrow's maximum temperature in °C
        4. Which of five species a photographed bird belongs to
        5. The amount of electricity a building will use next month, in kWh

        ExamWorked exam answer

        A hospital has records of 2000 patients, each with the patient's age and the number of days they stayed in hospital after an operation. Explain how linear regression could be used to predict how long a new patient will stay.

        [4]
          Try writing your own answer first.

          ReviewMistakes examiners see

          Misconception

          Using linear regression to predict a category. It predicts a number on a continuous scale.

          Misconception

          Describing the slope as “how steep the line is” without saying what it means in context: the change in Y for each one-unit increase in X, in the units of the problem.

          Misconception

          Treating r² as the percentage of predictions that are correct. It is the proportion of the variation in Y that the model explains.

          Exam tip

          Predictions are most reliable inside the range of X values in the training data. Predicting outside it (extrapolation) assumes the straight line continues, which it may not.

          Exam practiceExam-style questions

          5 questions · 12 marks. Answer each one first, then mark it yourself against the markscheme. Your answers are saved in this browser only.

          Scenario

          A city's bike-sharing scheme recorded the number of bikes hired and the midday temperature on each of 365 days, when temperatures ranged from 2 °C to 31 °C. A linear regression model fitted to these records is hires = 420 + 38 × temperature, with r² = 0.58.

          (a)Identify · AO2[2]

          Identify the independent variable and the dependent variable in this model.

          (b)Explain · AO3[4]

          Explain the significance of the values 38 and 420 in the model.

          (c)Calculate · AO2[1]

          Calculate the number of hires the model predicts on a day when the midday temperature is 25 °C.

          (d)Explain · AO3[3]

          Explain what r² = 0.58 tells the scheme's managers about the model.

          (e)Suggest · AO3[2]

          The managers want a better model. Suggest one additional independent variable and how it would change the model.

          0 / 12

          0 of 5 questions marked. Mark every question to see your total.

          Exam-style questions written for Praxis IB in the format of the 2027 specimen papers. They are not IB past-paper questions.