Skip to content

Commit

Permalink
Liner regression update
Browse files Browse the repository at this point in the history
  • Loading branch information
trajanov committed Feb 5, 2025
1 parent bcde53b commit 5dda0fe
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@
"\n",
"Here, $\\theta_0$ is the intercept term, representing the value of $y$ when all input variables are zero.\n",
"\n",
"### Modified Cost Function\n",
"### Cost Function with Intercept\n",
"\n",
"The mean squared error (MSE) for the cost function now becomes:\n",
"\n",
"$$\n",
"L(\\theta_0, \\theta_1, \\theta_2, \\theta_3) = \\frac{1}{2n} \\sum_{i=1}^{n} \\left( y_i - (\\theta_0 + \\theta_1 x_{1i} + \\theta_2 x_{2i} + \\theta_3 x_{3i}) \\right)^2\n",
"$$\n",
"\n",
"### Modified Gradient Descent\n",
"### Gradient Descent with Intercept\n",
"\n",
"The steps in the gradient descent algorithm would be as follows:\n",
"\n",
Expand All @@ -463,14 +463,22 @@
"\\theta_j = \\theta_j - \\alpha \\frac{\\partial L}{\\partial \\theta_j} , \\quad \\text{for} \\; j=0,1,2,3\n",
"$$\n",
"\n",
"### Interpretation of Modified Coefficients\n",
"### Interpretation of Coefficients\n",
"\n",
"- $\\theta_0$ is the estimated value of the dependent variable when all the predictors are zero.\n",
"- $\\theta_1$, $\\theta_2$, $\\theta_3$ have similar interpretations as before, but they are adjusted for the presence of $\\theta_0$ and other variables.\n",
"\n",
"The introduction of the intercept term $\\theta_0$ allows the model to better capture the relationship between the dependent variable and the predictors, thereby enhancing its predictive accuracy."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate Data.\n",
"Prepare data for the linear regression model with an intercept term."
]
},
{
"cell_type": "code",
"execution_count": 19,
Expand Down Expand Up @@ -531,6 +539,9 @@
"$$\n",
"X_i = (1, x_1, x_2, x_3)\n",
"$$\n",
"$$\n",
"\\theta = (\\theta_0, \\theta_1, \\theta_2, \\theta_3)\n",
"$$\n",
"\n",
"The mean squared error (MSE) for the cost function now becomes:\n",
"\n",
Expand Down

0 comments on commit 5dda0fe

Please sign in to comment.