|
3518 | 3518 | }, |
3519 | 3519 | { |
3520 | 3520 | "cell_type": "code", |
3521 | | - "execution_count": 10, |
| 3521 | + "execution_count": 6, |
3522 | 3522 | "id": "2ed0cafc", |
3523 | 3523 | "metadata": { |
3524 | 3524 | "collapsed": false, |
|
3539 | 3539 | "0.004113634617443139\n", |
3540 | 3540 | "MSE with intercept column from SKL\n", |
3541 | 3541 | "0.004113634617443147\n", |
3542 | | - "Manual intercept: 2.083766322923907\n", |
| 3542 | + "Manual intercept: 2.083766322923899\n", |
3543 | 3543 | "Fitted theta (without intercept): [0.19569961 3.97898392]\n", |
3544 | 3544 | "Sklearn intercept: 2.0837663229239043\n", |
3545 | 3545 | "Sklearn fitted theta (without intercept): [0.19569961 3.97898392]\n", |
3546 | 3546 | "MSE with Manual intercept\n", |
3547 | | - "4.346195723169266\n", |
| 3547 | + "0.00411363461744314\n", |
3548 | 3548 | "MSE with Sklearn intercept\n", |
3549 | 3549 | "0.004113634617443131\n" |
3550 | 3550 | ] |
|
3627 | 3627 | "y_offset = np.average(y, axis=0)\n", |
3628 | 3628 | "X_offset = np.average(X, axis=0)\n", |
3629 | 3629 | "\n", |
3630 | | - "theta = fit_theta(X - X_offset, y)#-y_offset)\n", |
| 3630 | + "theta = fit_theta(X - X_offset, y-y_offset)\n", |
3631 | 3631 | "intercept = np.mean(y_offset - X_offset @ theta)\n", |
3632 | 3632 | "\n", |
3633 | 3633 | "print(f\"Manual intercept: {intercept}\")\n", |
|
3637 | 3637 | "ypredictOwn = X @ theta\n", |
3638 | 3638 | "ypredictSKL = skl.predict(X)\n", |
3639 | 3639 | "print(f\"MSE with Manual intercept\")\n", |
3640 | | - "print(MSE(y,ypredictOwn))#+intercept))\n", |
| 3640 | + "print(MSE(y,ypredictOwn+intercept))\n", |
3641 | 3641 | "print(f\"MSE with Sklearn intercept\")\n", |
3642 | 3642 | "print(MSE(y,ypredictSKL))\n", |
3643 | 3643 | "\n", |
|
3745 | 3745 | }, |
3746 | 3746 | { |
3747 | 3747 | "cell_type": "code", |
3748 | | - "execution_count": 11, |
| 3748 | + "execution_count": 4, |
3749 | 3749 | "id": "4f9b1fa0", |
3750 | 3750 | "metadata": { |
3751 | 3751 | "collapsed": false, |
|
3943 | 3943 | }, |
3944 | 3944 | { |
3945 | 3945 | "cell_type": "code", |
3946 | | - "execution_count": 12, |
| 3946 | + "execution_count": 5, |
3947 | 3947 | "id": "a731e32c", |
3948 | 3948 | "metadata": { |
3949 | 3949 | "collapsed": false, |
|
0 commit comments