update on today's lectures

This commit is contained in:
Morten Hjorth-Jensen
2021-10-21 08:10:45 +02:00
parent 8630bcf4b3
commit f263050011
101 changed files with 3251 additions and 1854 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -475,7 +475,7 @@
"output_type": "stream",
"text": [
"Converged at iteration 5\n",
"Runtime: 0.4884450435638428 seconds\n"
"Runtime: 0.4787557125091553 seconds\n"
]
}
],
@@ -604,7 +604,7 @@
"output_type": "stream",
"text": [
"Converged at iteration: 5\n",
"Runtime: 0.44310808181762695 seconds\n"
"Runtime: 0.4250478744506836 seconds\n"
]
}
],
@@ -745,7 +745,7 @@
"output_type": "stream",
"text": [
"Converged at iteration: 11\n",
"Runtime: 0.8929829597473145 seconds\n",
"Runtime: 0.8499350547790527 seconds\n",
" "
]
}
@@ -877,7 +877,7 @@
"output_type": "stream",
"text": [
"Converged at iteration: 5\n",
"Runtime: 0.0037839412689208984 seconds\n"
"Runtime: 0.003952980041503906 seconds\n"
]
}
],
File diff suppressed because one or more lines are too long
@@ -2120,16 +2120,13 @@ TestError = np.zeros(maxdegree)
TrainError = np.zeros(maxdegree)
polydegree = np.zeros(maxdegree)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
scaler = StandardScaler()
scaler.fit(x_train)
x_train_scaled = scaler.transform(x_train)
x_test_scaled = scaler.transform(x_test)
for degree in range(maxdegree):
model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
clf = model.fit(x_train_scaled,y_train)
y_fit = clf.predict(x_train_scaled)
y_pred = clf.predict(x_test_scaled)
clf = model.fit(x_train,y_train)
y_fit = clf.predict(x_train)
y_pred = clf.predict(x_test)
polydegree[degree] = degree
TestError[degree] = np.mean( np.mean((y_test - y_pred)**2) )
TrainError[degree] = np.mean( np.mean((y_train - y_fit)**2) )
@@ -2400,7 +2400,13 @@
"Learning rate = 10.0\n",
"Lambda = 0.01\n",
"Accuracy score on test set: 0.08888888888888889\n",
"\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Learning rate = 10.0\n",
"Lambda = 0.1\n",
"Accuracy score on test set: 0.10555555555555556\n",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 25 KiB

+4 -7
View File
@@ -3411,16 +3411,13 @@
"TrainError = np.zeros(maxdegree)\n",
"polydegree = np.zeros(maxdegree)\n",
"x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
"scaler = StandardScaler()\n",
"scaler.fit(x_train)\n",
"x_train_scaled = scaler.transform(x_train)\n",
"x_test_scaled = scaler.transform(x_test)\n",
"\n",
"\n",
"for degree in range(maxdegree):\n",
" model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))\n",
" clf = model.fit(x_train_scaled,y_train)\n",
" y_fit = clf.predict(x_train_scaled)\n",
" y_pred = clf.predict(x_test_scaled) \n",
" clf = model.fit(x_train,y_train)\n",
" y_fit = clf.predict(x_train)\n",
" y_pred = clf.predict(x_test) \n",
" polydegree[degree] = degree\n",
" TestError[degree] = np.mean( np.mean((y_test - y_pred)**2) )\n",
" TrainError[degree] = np.mean( np.mean((y_train - y_fit)**2) )\n",