Write a function that fits a basic simple linear regression model using ordinary least squares. Given paired training data x and y, compute the best-fit line y = m*x + b, then use it to predict outputs for a list of query values.
Implement a function that takes:
x: a list of numbers representing the independent variabley: a list of numbers representing the dependent variablequeries: a list of numbers to predictReturn a list of predicted values for each query, using the fitted line.
Use the least-squares formulas:
m = sum((xi - mean_x) * (yi - mean_y)) / sum((xi - mean_x)^2)b = mean_y - m * mean_xIf all x values are identical, the slope is undefined. In that case, return the mean of y for every query.
def fit_linear_regression(x, y, queries):