hi

Why does the lab use squeeze function in this code segment?

I explored that the function squeezes the dimension of an array. But as far as I understand mse is a float rather than an array so why do we need that function?

yhat = linear_model.predict(X_train_scaled)

print(f"training MSE (using sklearn function): {mean_squared_error(y_train, yhat) / 2}")

total_squared_error = 0

for i in range(len(yhat)):

squared_error_i = (yhat[i] - y_train[i])**2

total_squared_error += squared_error_i

mse = total_squared_error / (2*len(yhat))

print(f"training MSE (for-loop implementation): {mse.squeeze()}")