Regression_Examples_and_Solutions_Fixed
Regression_Examples_and_Solutions_Fixed
Formula:
Y = b0 + b1 X
Y: Dependent variable
X: Independent variable
b0: Intercept
b1: Slope
Example Question:
Given: X = [1, 2, 3] and Y = [2, 4, 5]. Find the regression line equation.
Solution:
2. Compute slope:
3. Intercept:
Formula:
Y = b0 + b1 * X1 + b2 * X2
Page 1
Formulas and Examples with Solutions
Example Question:
Predict Y using X1 = [1, 2] and X2 = [3, 4] where Y = [5, 6]. Find coefficients.
Solution:
Formula:
Example Question:
Solution:
Slope (b1):
Intercept (b0):
b0 = Y_mean - b1 * X_mean
Example Question:
Page 2
Formulas and Examples with Solutions
Solution:
b1 = 1.5, b0 = 0.67
5. Gradient Descent
Formula:
Example Question:
Initial theta = 0.5, learning rate (alpha) = 0.1, partial derivative = 0.2.
Solution:
Formula:
Example Question:
Solution:
Formula:
Page 3
Formulas and Examples with Solutions
Example Question:
Solution:
Formula:
RMSE = sqrt(MSE)
Example Question:
Solution:
9. R-squared (R^2)
Formula:
Example Question:
Solution:
Page 4
Formulas and Examples with Solutions
Formula:
Example Question:
Predicted: [2.5, 4.5], Actual: [3, 5], lambda = 0.1. Compute cost.
Solution:
Formula:
Example Question:
Predicted: [2.5, 4.5], Actual: [3, 5], lambda = 0.1. Compute cost.
Solution:
Page 5