Experiment 5 Code
Experiment 5 Code
import numpy as np
import matplotlib.pyplot as plt
# Data points
X = np.array([70, 80, 90, 100, 110, 120, 130, 140, 150, 160])
Y = np.array([7, 7, 8, 9, 12, 12, 15, 14, 13, 17])
# Calculate the sums needed for the slope (w1) and intercept (w0)
sum_X = np.sum(X)
sum_Y = np.sum(Y)
sum_XY = np.sum(X * Y)
sum_X2 = np.sum(X**2)
# import numpy as np
# import matplotlib.pyplot as plt
# # Data points
# X = np.array([70, 80, 90, 100, 110, 120, 130, 140, 150, 160])
# Y = np.array([7, 7, 8, 9, 12, 12, 15, 14, 13, 17])
# # Calculate the sums needed for the slope (w1) and intercept (w0)
# sum_X = np.sum(X)
# sum_Y = np.sum(Y)
# sum_XY = np.sum(X * Y)
# sum_X2 = np.sum(X**2)
# # Plotting
# # Create a range of X values for plotting the regression line
# X_line = np.linspace(min(X), max(X_new, max(X)), 100)
# Y_line = w0 + w1 * X_line
# # Show legend
# plt.legend()