Update week37.ipynb
This commit is contained in:
@@ -3518,7 +3518,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 10,
|
||||
"id": "2ed0cafc",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
@@ -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",
|
||||
@@ -3745,7 +3745,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 11,
|
||||
"id": "4f9b1fa0",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
@@ -3943,7 +3943,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 12,
|
||||
"id": "a731e32c",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
@@ -4109,6 +4109,7 @@
|
||||
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n",
|
||||
"\n",
|
||||
"#For our own implementation, we will need to deal with the intercept by centering the design matrix and the target variable\n",
|
||||
"\n",
|
||||
"X_train_mean = np.mean(X_train,axis=0)\n",
|
||||
"#Center by removing mean from each feature\n",
|
||||
"X_train_scaled = X_train - X_train_mean \n",
|
||||
|
||||
Reference in New Issue
Block a user