update week34
This commit is contained in:
@@ -629,8 +629,8 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"$$\n",
|
||||
"H_{\\delta}(a)=\\left\\{\\begin{array}\\frac{1}{2}a^{2}&{\\text{for }}|a|\\leq \\delta ,\\\\ \\delta (|a|-\\frac {1}{2}\\del\\\n",
|
||||
"ta ),&{\\text{otherwise.}\\end{array}\\right.\n",
|
||||
"H_{\\delta}(\\boldsymbol{a})=\\left\\{\\begin{array}{cc}\\frac{1}{2} \\boldsymbol{a}^{2}& \\text{for }|\\boldsymbol{a}|\\leq \\delta\\\\ \\delta (|\\b\\\n",
|
||||
"m{a}|-\\frac{1}{2}\\delta ),&\\text{otherwise}.\\end{array}\\right.\n",
|
||||
"$$"
|
||||
]
|
||||
},
|
||||
@@ -638,7 +638,9 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Here $a=\\boldsymbol{y} - \\boldsymbol{\\tilde{y}}$.\n",
|
||||
"Here $\\boldsymbol{a}=\\boldsymbol{y} - \\boldsymbol{\\tilde{y}}$.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"We will discuss in more\n",
|
||||
"detail these and other functions in the various lectures. We conclude this part with another example. Instead of \n",
|
||||
"a linear $x$-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn."
|
||||
@@ -3412,7 +3414,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# split in training and test data\n",
|
||||
"X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2)"
|
||||
"# X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3475,18 +3477,27 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"where $y$ is the function we want to fit with a given polynomial.\n",
|
||||
"!bsubex\n",
|
||||
"Write a first code which sets up a design matrix $X$ defined by a fifth-order polynomial. Scale your data and split it in training and test data. \n",
|
||||
"!esubex\n",
|
||||
"\n",
|
||||
"!bsubex\n",
|
||||
"Perform an ordinary least squares and compute the means squared error and the $R2$ factor for the training data and the test data, with and without scaling.\n",
|
||||
"!esubex\n",
|
||||
"\n",
|
||||
"!bsubex\n",
|
||||
"Add now a model which allows you to make polynomials up to degree $15$. Perform a standard OLS fitting of the training data and compute the MSE and $R2$ for the training and test data and plot both test and training data MSE and $R2$ as functions of the polynomial degree. Compare what you see with Figure 2.11 of Hastie et al. Comment your results. For which polynomial degree do you find an optimal MSE (smallest value)?\n",
|
||||
"Write a first code which sets up a design matrix $X$ defined by a\n",
|
||||
"fifth-order polynomial. Scale your data and split it in training and\n",
|
||||
"test data.\n",
|
||||
"\n",
|
||||
"!esubex"
|
||||
"\n",
|
||||
"\n",
|
||||
"Perform an ordinary least squares and compute the means squared error\n",
|
||||
"and the $R2$ factor for the training data and the test data, with and\n",
|
||||
"without scaling.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Add now a model which allows you to make polynomials up to degree\n",
|
||||
"$15$. Perform a standard OLS fitting of the training data and compute\n",
|
||||
"the MSE and $R2$ for the training and test data and plot both test and\n",
|
||||
"training data MSE and $R2$ as functions of the polynomial\n",
|
||||
"degree. Compare what you see with Figure 2.11 of Hastie et al. Comment\n",
|
||||
"your results. For which polynomial degree do you find an optimal MSE\n",
|
||||
"(smallest value)?"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user