Update week37.ipynb

This commit is contained in:
Morten Hjorth-Jensen
2025-09-10 10:29:01 +02:00
parent 7a05286ce7
commit cee5f8e1f0
+7 -7
View File
@@ -3518,7 +3518,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"id": "2ed0cafc",
"metadata": {
"collapsed": false,
@@ -3539,12 +3539,12 @@
"0.004113634617443139\n",
"MSE with intercept column from SKL\n",
"0.004113634617443147\n",
"Manual intercept: 2.083766322923907\n",
"Manual intercept: 2.083766322923899\n",
"Fitted theta (without intercept): [0.19569961 3.97898392]\n",
"Sklearn intercept: 2.0837663229239043\n",
"Sklearn fitted theta (without intercept): [0.19569961 3.97898392]\n",
"MSE with Manual intercept\n",
"4.346195723169266\n",
"0.00411363461744314\n",
"MSE with Sklearn intercept\n",
"0.004113634617443131\n"
]
@@ -3627,7 +3627,7 @@
"y_offset = np.average(y, axis=0)\n",
"X_offset = np.average(X, axis=0)\n",
"\n",
"theta = fit_theta(X - X_offset, y)#-y_offset)\n",
"theta = fit_theta(X - X_offset, y-y_offset)\n",
"intercept = np.mean(y_offset - X_offset @ theta)\n",
"\n",
"print(f\"Manual intercept: {intercept}\")\n",
@@ -3637,7 +3637,7 @@
"ypredictOwn = X @ theta\n",
"ypredictSKL = skl.predict(X)\n",
"print(f\"MSE with Manual intercept\")\n",
"print(MSE(y,ypredictOwn))#+intercept))\n",
"print(MSE(y,ypredictOwn+intercept))\n",
"print(f\"MSE with Sklearn intercept\")\n",
"print(MSE(y,ypredictSKL))\n",
"\n",
@@ -3745,7 +3745,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 4,
"id": "4f9b1fa0",
"metadata": {
"collapsed": false,
@@ -3943,7 +3943,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"id": "a731e32c",
"metadata": {
"collapsed": false,