Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-343

Prediction from OLS Fit

Problem

A fitted simple regression predicts y_hat = intercept + slope * x_new.

Given the slope, the intercept, and a new predictor value, return the prediction.

Hint

Evaluate the fitted line at the new point.

Test cases

case 1
in: [2,1,3]
expected: 7
case 2
in: [0,5,10]
expected: 5
case 3
in: [-1.5,2,4]
expected: -4
Starter codePython
def prediction_from_ols_fit(slope, intercept, x_new):
    # Your code here
    pass

3 test cases · run your code against them in the editor