Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
468 B
2
Indexable
Never
X = [1, 0, 0, 1, 2, 2.5, 3, 4, 4, 5, 5]
Y = [7, 1, 2, 1, 2, 2, 3.5, 3.5, 5, 4, 6]

# Define lines
line1 = lambda x: x + 1
line2 = lambda x: x + 0.5

# Calculate MSE for Line 1
MSE_Line1 = sum((y - (line1(x) + 1))**2 for x, y in zip(X, Y)) / len(X)

# Calculate MSE for Line 2
MSE_Line2 = sum((y - (line2(x) + 0.5))**2 for x, y in zip(X, Y)) / len(X)

# Print MSE for both lines
print(f"MSE for Line 1: {MSE_Line1}")
print(f"MSE for Line 2: {MSE_Line2}")