587 lines
35 KiB
HTML
587 lines
35 KiB
HTML
<!--
|
|
HTML file automatically generated from DocOnce source
|
|
(https://github.com/doconce/doconce/)
|
|
doconce format html week34.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week34-bs --no_mako
|
|
-->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<meta name="description" content="Week 34: Introduction to the course, Logistics and Practicalities">
|
|
<title>Week 34: Introduction to the course, Logistics and Practicalities</title>
|
|
<!-- Bootstrap style: bootstrap -->
|
|
<!-- doconce format html week34.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week34-bs --no_mako -->
|
|
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
|
<!-- not necessary
|
|
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
|
-->
|
|
<style type="text/css">
|
|
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
|
.dropdown-menu {
|
|
height: auto;
|
|
max-height: 400px;
|
|
overflow-x: hidden;
|
|
}
|
|
/* Adds an invisible element before each target to offset for the navigation
|
|
bar */
|
|
.anchor::before {
|
|
content:"";
|
|
display:block;
|
|
height:50px; /* fixed header height for style bootstrap */
|
|
margin:-50px 0 0; /* negative fixed header height */
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<!-- tocinfo
|
|
{'highest level': 2,
|
|
'sections': [('Overview of first week', 2, None, 'overview-of-first-week'),
|
|
('Schedule first week', 2, None, 'schedule-first-week'),
|
|
('Lectures and ComputerLab', 2, None, 'lectures-and-computerlab'),
|
|
('Communication channels', 2, None, 'communication-channels'),
|
|
('Course Format', 2, None, 'course-format'),
|
|
('Teachers', 2, None, 'teachers'),
|
|
('Deadlines for projects (tentative)',
|
|
2,
|
|
None,
|
|
'deadlines-for-projects-tentative'),
|
|
('Grading', 2, None, 'grading'),
|
|
('Reading material', 2, None, 'reading-material'),
|
|
('Main textbooks', 2, None, 'main-textbooks'),
|
|
('Other popular texts', 2, None, 'other-popular-texts'),
|
|
('Reading suggestions week 34',
|
|
2,
|
|
None,
|
|
'reading-suggestions-week-34'),
|
|
('Prerequisites', 2, None, 'prerequisites'),
|
|
('Topics covered in this course: Statistical analysis and '
|
|
'optimization of data',
|
|
2,
|
|
None,
|
|
'topics-covered-in-this-course-statistical-analysis-and-optimization-of-data'),
|
|
('Statistical analysis and optimization of data',
|
|
2,
|
|
None,
|
|
'statistical-analysis-and-optimization-of-data'),
|
|
('Machine Learning', 2, None, 'machine-learning'),
|
|
('Deep learning methods', 2, None, 'deep-learning-methods'),
|
|
('Extremely useful tools, strongly recommended',
|
|
2,
|
|
None,
|
|
'extremely-useful-tools-strongly-recommended'),
|
|
('Other courses on Data science and Machine Learning at UiO',
|
|
2,
|
|
None,
|
|
'other-courses-on-data-science-and-machine-learning-at-uio'),
|
|
('Other courses on Data science and Machine Learning at UiO, '
|
|
'contn',
|
|
2,
|
|
None,
|
|
'other-courses-on-data-science-and-machine-learning-at-uio-contn'),
|
|
('Learning outcomes', 2, None, 'learning-outcomes'),
|
|
('Types of Machine Learning',
|
|
2,
|
|
None,
|
|
'types-of-machine-learning'),
|
|
('Essential elements of ML', 2, None, 'essential-elements-of-ml'),
|
|
('An optimization/minimization problem',
|
|
2,
|
|
None,
|
|
'an-optimization-minimization-problem'),
|
|
('A Frequentist approach to data analysis',
|
|
2,
|
|
None,
|
|
'a-frequentist-approach-to-data-analysis'),
|
|
('What is a good model?', 2, None, 'what-is-a-good-model'),
|
|
('What is a good model? Can we define it?',
|
|
2,
|
|
None,
|
|
'what-is-a-good-model-can-we-define-it'),
|
|
('Software and needed installations',
|
|
2,
|
|
None,
|
|
'software-and-needed-installations'),
|
|
('Python installers', 2, None, 'python-installers'),
|
|
('Useful Python libraries', 2, None, 'useful-python-libraries'),
|
|
('Installing R, C++, cython or Julia',
|
|
2,
|
|
None,
|
|
'installing-r-c-cython-or-julia'),
|
|
('Installing R, C++, cython, Numba etc',
|
|
2,
|
|
None,
|
|
'installing-r-c-cython-numba-etc'),
|
|
('Numpy examples and Important Matrix and vector handling '
|
|
'packages',
|
|
2,
|
|
None,
|
|
'numpy-examples-and-important-matrix-and-vector-handling-packages'),
|
|
('Numpy and arrays', 2, None, 'numpy-and-arrays'),
|
|
('Matrices in Python', 2, None, 'matrices-in-python'),
|
|
('Meet the Pandas', 2, None, 'meet-the-pandas'),
|
|
('Pandas AI', 2, None, 'pandas-ai'),
|
|
('Simple linear regression model using _scikit-learn_',
|
|
3,
|
|
None,
|
|
'simple-linear-regression-model-using-scikit-learn'),
|
|
('To our real data: nuclear binding energies. Brief reminder on '
|
|
'masses and binding energies',
|
|
3,
|
|
None,
|
|
'to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies'),
|
|
('Organizing our data', 3, None, 'organizing-our-data'),
|
|
('And what about using neural networks?',
|
|
3,
|
|
None,
|
|
'and-what-about-using-neural-networks'),
|
|
('A first summary', 2, None, 'a-first-summary'),
|
|
('Why Linear Regression (aka Ordinary Least Squares and family)',
|
|
2,
|
|
None,
|
|
'why-linear-regression-aka-ordinary-least-squares-and-family'),
|
|
('Regression analysis, overarching aims',
|
|
2,
|
|
None,
|
|
'regression-analysis-overarching-aims'),
|
|
('Regression analysis, overarching aims II',
|
|
2,
|
|
None,
|
|
'regression-analysis-overarching-aims-ii'),
|
|
('Examples', 2, None, 'examples'),
|
|
('General linear models and linear algebra',
|
|
2,
|
|
None,
|
|
'general-linear-models-and-linear-algebra'),
|
|
('Rewriting the fitting procedure as a linear algebra problem',
|
|
2,
|
|
None,
|
|
'rewriting-the-fitting-procedure-as-a-linear-algebra-problem'),
|
|
('Rewriting the fitting procedure as a linear algebra problem, '
|
|
'more details',
|
|
2,
|
|
None,
|
|
'rewriting-the-fitting-procedure-as-a-linear-algebra-problem-more-details'),
|
|
('Generalizing the fitting procedure as a linear algebra problem',
|
|
2,
|
|
None,
|
|
'generalizing-the-fitting-procedure-as-a-linear-algebra-problem'),
|
|
('Generalizing the fitting procedure as a linear algebra problem',
|
|
2,
|
|
None,
|
|
'generalizing-the-fitting-procedure-as-a-linear-algebra-problem'),
|
|
('Optimizing our parameters',
|
|
2,
|
|
None,
|
|
'optimizing-our-parameters'),
|
|
('Our model for the nuclear binding energies',
|
|
2,
|
|
None,
|
|
'our-model-for-the-nuclear-binding-energies'),
|
|
('Optimizing our parameters, more details',
|
|
2,
|
|
None,
|
|
'optimizing-our-parameters-more-details'),
|
|
('Interpretations and optimizing our parameters',
|
|
2,
|
|
None,
|
|
'interpretations-and-optimizing-our-parameters'),
|
|
('Interpretations and optimizing our parameters',
|
|
2,
|
|
None,
|
|
'interpretations-and-optimizing-our-parameters'),
|
|
('Interpretations and optimizing our parameters',
|
|
2,
|
|
None,
|
|
'interpretations-and-optimizing-our-parameters'),
|
|
('Own code for Ordinary Least Squares',
|
|
2,
|
|
None,
|
|
'own-code-for-ordinary-least-squares'),
|
|
('Adding error analysis and training set up',
|
|
2,
|
|
None,
|
|
'adding-error-analysis-and-training-set-up'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('The $\\chi^2$ function', 2, None, 'the-chi-2-function'),
|
|
('Fitting an Equation of State for Dense Nuclear Matter',
|
|
2,
|
|
None,
|
|
'fitting-an-equation-of-state-for-dense-nuclear-matter'),
|
|
('The code', 2, None, 'the-code'),
|
|
('Splitting our Data in Training and Test data',
|
|
2,
|
|
None,
|
|
'splitting-our-data-in-training-and-test-data'),
|
|
('Exercises', 2, None, 'exercises'),
|
|
('Exercise 1: Setting up various Python environments',
|
|
2,
|
|
None,
|
|
'exercise-1-setting-up-various-python-environments'),
|
|
('Exercise 2: making your own data and exploring scikit-learn',
|
|
2,
|
|
None,
|
|
'exercise-2-making-your-own-data-and-exploring-scikit-learn'),
|
|
('Exercise 3: Split data in test and training data',
|
|
2,
|
|
None,
|
|
'exercise-3-split-data-in-test-and-training-data')]}
|
|
end of tocinfo -->
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
TeX: {
|
|
equationNumbers: { autoNumber: "none" },
|
|
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
|
}
|
|
});
|
|
</script>
|
|
<script type="text/javascript" async
|
|
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
|
</script>
|
|
|
|
|
|
<!-- Bootstrap navigation bar -->
|
|
<div class="navbar navbar-default navbar-fixed-top">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="week34-bs.html">Week 34: Introduction to the course, Logistics and Practicalities</a>
|
|
</div>
|
|
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
|
<ul class="nav navbar-nav navbar-right">
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
|
<ul class="dropdown-menu">
|
|
<!-- navigation toc: --> <li><a href="._week34-bs001.html#overview-of-first-week" style="font-size: 80%;"><b>Overview of first week</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs002.html#schedule-first-week" style="font-size: 80%;"><b>Schedule first week</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs003.html#lectures-and-computerlab" style="font-size: 80%;"><b>Lectures and ComputerLab</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs004.html#communication-channels" style="font-size: 80%;"><b>Communication channels</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs005.html#course-format" style="font-size: 80%;"><b>Course Format</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs006.html#teachers" style="font-size: 80%;"><b>Teachers</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs007.html#deadlines-for-projects-tentative" style="font-size: 80%;"><b>Deadlines for projects (tentative)</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs008.html#grading" style="font-size: 80%;"><b>Grading</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs009.html#reading-material" style="font-size: 80%;"><b>Reading material</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs010.html#main-textbooks" style="font-size: 80%;"><b>Main textbooks</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs011.html#other-popular-texts" style="font-size: 80%;"><b>Other popular texts</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs012.html#reading-suggestions-week-34" style="font-size: 80%;"><b>Reading suggestions week 34</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs013.html#prerequisites" style="font-size: 80%;"><b>Prerequisites</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs014.html#topics-covered-in-this-course-statistical-analysis-and-optimization-of-data" style="font-size: 80%;"><b>Topics covered in this course: Statistical analysis and optimization of data</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs015.html#statistical-analysis-and-optimization-of-data" style="font-size: 80%;"><b>Statistical analysis and optimization of data</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs016.html#machine-learning" style="font-size: 80%;"><b>Machine Learning</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs017.html#deep-learning-methods" style="font-size: 80%;"><b>Deep learning methods</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs018.html#extremely-useful-tools-strongly-recommended" style="font-size: 80%;"><b>Extremely useful tools, strongly recommended</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs019.html#other-courses-on-data-science-and-machine-learning-at-uio" style="font-size: 80%;"><b>Other courses on Data science and Machine Learning at UiO</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs020.html#other-courses-on-data-science-and-machine-learning-at-uio-contn" style="font-size: 80%;"><b>Other courses on Data science and Machine Learning at UiO, contn</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs021.html#learning-outcomes" style="font-size: 80%;"><b>Learning outcomes</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs022.html#types-of-machine-learning" style="font-size: 80%;"><b>Types of Machine Learning</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs023.html#essential-elements-of-ml" style="font-size: 80%;"><b>Essential elements of ML</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs024.html#an-optimization-minimization-problem" style="font-size: 80%;"><b>An optimization/minimization problem</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs025.html#a-frequentist-approach-to-data-analysis" style="font-size: 80%;"><b>A Frequentist approach to data analysis</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs026.html#what-is-a-good-model" style="font-size: 80%;"><b>What is a good model?</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs027.html#what-is-a-good-model-can-we-define-it" style="font-size: 80%;"><b>What is a good model? Can we define it?</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs028.html#software-and-needed-installations" style="font-size: 80%;"><b>Software and needed installations</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs029.html#python-installers" style="font-size: 80%;"><b>Python installers</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs030.html#useful-python-libraries" style="font-size: 80%;"><b>Useful Python libraries</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs031.html#installing-r-c-cython-or-julia" style="font-size: 80%;"><b>Installing R, C++, cython or Julia</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs032.html#installing-r-c-cython-numba-etc" style="font-size: 80%;"><b>Installing R, C++, cython, Numba etc</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs033.html#numpy-examples-and-important-matrix-and-vector-handling-packages" style="font-size: 80%;"><b>Numpy examples and Important Matrix and vector handling packages</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs034.html#numpy-and-arrays" style="font-size: 80%;"><b>Numpy and arrays</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs035.html#matrices-in-python" style="font-size: 80%;"><b>Matrices in Python</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs036.html#meet-the-pandas" style="font-size: 80%;"><b>Meet the Pandas</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs037.html#pandas-ai" style="font-size: 80%;"><b>Pandas AI</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs038.html#simple-linear-regression-model-using-scikit-learn" style="font-size: 80%;"> Simple linear regression model using <b>scikit-learn</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs038.html#to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies" style="font-size: 80%;"> To our real data: nuclear binding energies. Brief reminder on masses and binding energies</a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs038.html#organizing-our-data" style="font-size: 80%;"> Organizing our data</a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs038.html#and-what-about-using-neural-networks" style="font-size: 80%;"> And what about using neural networks?</a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs038.html#a-first-summary" style="font-size: 80%;"><b>A first summary</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs039.html#why-linear-regression-aka-ordinary-least-squares-and-family" style="font-size: 80%;"><b>Why Linear Regression (aka Ordinary Least Squares and family)</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs040.html#regression-analysis-overarching-aims" style="font-size: 80%;"><b>Regression analysis, overarching aims</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs041.html#regression-analysis-overarching-aims-ii" style="font-size: 80%;"><b>Regression analysis, overarching aims II</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs042.html#examples" style="font-size: 80%;"><b>Examples</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs043.html#general-linear-models-and-linear-algebra" style="font-size: 80%;"><b>General linear models and linear algebra</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs044.html#rewriting-the-fitting-procedure-as-a-linear-algebra-problem" style="font-size: 80%;"><b>Rewriting the fitting procedure as a linear algebra problem</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs045.html#rewriting-the-fitting-procedure-as-a-linear-algebra-problem-more-details" style="font-size: 80%;"><b>Rewriting the fitting procedure as a linear algebra problem, more details</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs047.html#generalizing-the-fitting-procedure-as-a-linear-algebra-problem" style="font-size: 80%;"><b>Generalizing the fitting procedure as a linear algebra problem</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs047.html#generalizing-the-fitting-procedure-as-a-linear-algebra-problem" style="font-size: 80%;"><b>Generalizing the fitting procedure as a linear algebra problem</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs048.html#optimizing-our-parameters" style="font-size: 80%;"><b>Optimizing our parameters</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs049.html#our-model-for-the-nuclear-binding-energies" style="font-size: 80%;"><b>Our model for the nuclear binding energies</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs050.html#optimizing-our-parameters-more-details" style="font-size: 80%;"><b>Optimizing our parameters, more details</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs053.html#interpretations-and-optimizing-our-parameters" style="font-size: 80%;"><b>Interpretations and optimizing our parameters</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs053.html#interpretations-and-optimizing-our-parameters" style="font-size: 80%;"><b>Interpretations and optimizing our parameters</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs053.html#interpretations-and-optimizing-our-parameters" style="font-size: 80%;"><b>Interpretations and optimizing our parameters</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs054.html#own-code-for-ordinary-least-squares" style="font-size: 80%;"><b>Own code for Ordinary Least Squares</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs055.html#adding-error-analysis-and-training-set-up" style="font-size: 80%;"><b>Adding error analysis and training set up</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs061.html#the-chi-2-function" style="font-size: 80%;"><b>The \( \chi^2 \) function</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs062.html#fitting-an-equation-of-state-for-dense-nuclear-matter" style="font-size: 80%;"><b>Fitting an Equation of State for Dense Nuclear Matter</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs063.html#the-code" style="font-size: 80%;"><b>The code</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="._week34-bs064.html#splitting-our-data-in-training-and-test-data" style="font-size: 80%;"><b>Splitting our Data in Training and Test data</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="#exercises" style="font-size: 80%;"><b>Exercises</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="#exercise-1-setting-up-various-python-environments" style="font-size: 80%;"><b>Exercise 1: Setting up various Python environments</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="#exercise-2-making-your-own-data-and-exploring-scikit-learn" style="font-size: 80%;"><b>Exercise 2: making your own data and exploring scikit-learn</b></a></li>
|
|
<!-- navigation toc: --> <li><a href="#exercise-3-split-data-in-test-and-training-data" style="font-size: 80%;"><b>Exercise 3: Split data in test and training data</b></a></li>
|
|
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div> <!-- end of navigation bar -->
|
|
<div class="container">
|
|
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
|
<a name="part0065"></a>
|
|
<!-- !split -->
|
|
<h2 id="exercises" class="anchor">Exercises </h2>
|
|
|
|
<p>Here are three possible exercises for week 34</p>
|
|
|
|
<!-- --- begin exercise --- -->
|
|
<h2 id="exercise-1-setting-up-various-python-environments" class="anchor">Exercise 1: Setting up various Python environments </h2>
|
|
|
|
<p>The first exercise here is of a mere technical art. We want you to have </p>
|
|
<ul>
|
|
<li> git as a version control software and to establish a user account on a provider like GitHub. Other providers like GitLab etc are equally fine. You can also use the University of Oslo <a href="https://www.uio.no/tjenester/it/maskin/filer/versjonskontroll/github.html" target="_self">GitHub facilities</a>.</li>
|
|
<li> Install various Python packages</li>
|
|
</ul>
|
|
<p>We will make extensive use of Python as programming language and its
|
|
myriad of available libraries. You will find
|
|
IPython/Jupyter notebooks invaluable in your work. You can run <b>R</b>
|
|
codes in the Jupyter/IPython notebooks, with the immediate benefit of
|
|
visualizing your data. You can also use compiled languages like C++,
|
|
Rust, Fortran etc if you prefer. The focus in these lectures will be
|
|
on Python.
|
|
</p>
|
|
|
|
<p>If you have Python installed (we recommend Python3) and you feel
|
|
pretty familiar with installing different packages, we recommend that
|
|
you install the following Python packages via <b>pip</b> as
|
|
</p>
|
|
|
|
<ol>
|
|
<li> pip install numpy scipy matplotlib ipython scikit-learn sympy pandas pillow</li>
|
|
</ol>
|
|
<p>For <b>Tensorflow</b>, we recommend following the instructions in the text of
|
|
<a href="http://shop.oreilly.com/product/0636920052289.do" target="_self">Aurelien Geron, Hands‑On Machine Learning with Scikit‑Learn and TensorFlow, O'Reilly</a>
|
|
</p>
|
|
|
|
<p>We will come back to <b>tensorflow</b> later. </p>
|
|
|
|
<p>For Python3, replace <b>pip</b> with <b>pip3</b>.</p>
|
|
|
|
<p>For OSX users we recommend, after having installed Xcode, to
|
|
install <b>brew</b>. Brew allows for a seamless installation of additional
|
|
software via for example
|
|
</p>
|
|
|
|
<ol>
|
|
<li> brew install python3</li>
|
|
</ol>
|
|
<p>For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution,
|
|
you can use <b>pip</b> as well and simply install Python as
|
|
</p>
|
|
|
|
<ol>
|
|
<li> sudo apt-get install python3 (or python for Python2.7)</li>
|
|
</ol>
|
|
<p>If you don't want to perform these operations separately and venture
|
|
into the hassle of exploring how to set up dependencies and paths, we
|
|
recommend two widely used distrubutions which set up all relevant
|
|
dependencies for Python, namely
|
|
</p>
|
|
|
|
<ul>
|
|
<li> <a href="https://docs.anaconda.com/" target="_self">Anaconda</a>,</li>
|
|
</ul>
|
|
<p>which is an open source
|
|
distribution of the Python and R programming languages for large-scale
|
|
data processing, predictive analytics, and scientific computing, that
|
|
aims to simplify package management and deployment. Package versions
|
|
are managed by the package management system <b>conda</b>.
|
|
</p>
|
|
|
|
<ul>
|
|
<li> <a href="https://www.enthought.com/product/canopy/" target="_self">Enthought canopy</a></li>
|
|
</ul>
|
|
<p>is a Python
|
|
distribution for scientific and analytic computing distribution and
|
|
analysis environment, available for free and under a commercial
|
|
license.
|
|
</p>
|
|
|
|
<p>We recommend using <b>Anaconda</b> if you are not too familiar with setting paths in a terminal environment.</p>
|
|
|
|
<!-- --- end exercise --- -->
|
|
|
|
<!-- --- begin exercise --- -->
|
|
<h2 id="exercise-2-making-your-own-data-and-exploring-scikit-learn" class="anchor">Exercise 2: making your own data and exploring scikit-learn </h2>
|
|
|
|
<p>We will generate our own dataset for a function \( y(x) \) where \( x \in [0,1] \) and defined by random numbers computed with the uniform distribution. The function \( y \) is a quadratic polynomial in \( x \) with added stochastic noise according to the normal distribution \( \cal {N}(0,1) \).
|
|
The following simple Python instructions define our \( x \) and \( y \) values (with 100 data points).
|
|
</p>
|
|
|
|
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
|
<div class="cell border-box-sizing code_cell rendered">
|
|
<div class="input">
|
|
<div class="inner_cell">
|
|
<div class="input_area">
|
|
<div class="highlight" style="background: #f8f8f8">
|
|
<pre style="line-height: 125%;">x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>rand(<span style="color: #666666">100</span>,<span style="color: #666666">1</span>)
|
|
y <span style="color: #666666">=</span> <span style="color: #666666">2.0+5*</span>x<span style="color: #666666">*</span>x<span style="color: #666666">+0.1*</span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>randn(<span style="color: #666666">100</span>,<span style="color: #666666">1</span>)
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="output_wrapper">
|
|
<div class="output">
|
|
<div class="output_area">
|
|
<div class="output_subarea output_stream output_stdout output_text">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<ol>
|
|
<li> Write your own code (following the examples under the <a href="https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/chapter1.html" target="_self">regression notes</a>) for computing the parametrization of the data set fitting a second-order polynomial.</li>
|
|
<li> Use thereafter <b>scikit-learn</b> (see again the examples in the regression slides) and compare with your own code.</li>
|
|
<li> Using scikit-learn, compute also the mean square error, a risk metric corresponding to the expected value of the squared (quadratic) error defined as</li>
|
|
</ol>
|
|
$$ MSE(\boldsymbol{y},\boldsymbol{\tilde{y}}) = \frac{1}{n}
|
|
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
|
|
$$
|
|
|
|
<p>and the \( R^2 \) score function.
|
|
If \( \tilde{\boldsymbol{y}}_i \) is the predicted value of the \( i-th \) sample and \( y_i \) is the corresponding true value, then the score \( R^2 \) is defined as
|
|
</p>
|
|
$$
|
|
R^2(\boldsymbol{y}, \tilde{\boldsymbol{y}}) = 1 - \frac{\sum_{i=0}^{n - 1} (y_i - \tilde{y}_i)^2}{\sum_{i=0}^{n - 1} (y_i - \bar{y})^2},
|
|
$$
|
|
|
|
<p>where we have defined the mean value of \( \boldsymbol{y} \) as</p>
|
|
$$
|
|
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
|
|
$$
|
|
|
|
<p>You can use the functionality included in scikit-learn. If you feel for it, you can use your own program and define functions which compute the above two functions.
|
|
Discuss the meaning of these results. Try also to vary the coefficient in front of the added stochastic noise term and discuss the quality of the fits.
|
|
</p>
|
|
|
|
<!-- --- end exercise --- -->
|
|
|
|
<!-- --- begin exercise --- -->
|
|
<h2 id="exercise-3-split-data-in-test-and-training-data" class="anchor">Exercise 3: Split data in test and training data </h2>
|
|
|
|
<p>In this exercise we want you to to compute the MSE for the training
|
|
data and the test data as function of the complexity of a polynomial,
|
|
that is the degree of a given polynomial.
|
|
</p>
|
|
|
|
<p>The aim is to reproduce Figure 2.11 of <a href="https://github.com/CompPhysics/MLErasmus/blob/master/doc/Textbooks/elementsstat.pdf" target="_self">Hastie et al</a>.</p>
|
|
|
|
<p>Our data is defined by \( x\in [-3,3] \) with a total of for example \( n=100 \) data points. You should try to vary the number of data points \( n \) in your analysis.</p>
|
|
|
|
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
|
<div class="cell border-box-sizing code_cell rendered">
|
|
<div class="input">
|
|
<div class="inner_cell">
|
|
<div class="input_area">
|
|
<div class="highlight" style="background: #f8f8f8">
|
|
<pre style="line-height: 125%;">np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>seed()
|
|
n <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
|
<span style="color: #408080; font-style: italic"># Make data set.</span>
|
|
x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(<span style="color: #666666">-3</span>, <span style="color: #666666">3</span>, n)<span style="color: #666666">.</span>reshape(<span style="color: #666666">-1</span>, <span style="color: #666666">1</span>)
|
|
y <span style="color: #666666">=</span> np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>x<span style="color: #666666">**2</span>) <span style="color: #666666">+</span> <span style="color: #666666">1.5</span> <span style="color: #666666">*</span> np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>(x<span style="color: #666666">-2</span>)<span style="color: #666666">**2</span>)<span style="color: #666666">+</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>normal(<span style="color: #666666">0</span>, <span style="color: #666666">0.1</span>, x<span style="color: #666666">.</span>shape)
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="output_wrapper">
|
|
<div class="output">
|
|
<div class="output_area">
|
|
<div class="output_subarea output_stream output_stdout output_text">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<p>where \( y \) is the function we want to fit with a given polynomial.</p>
|
|
|
|
<!-- --- begin subexercise --- -->
|
|
<p>
|
|
<b>a)</b>
|
|
Write a first code which sets up a design matrix \( X \) defined by a fifth-order polynomial and split your data set in training and test data.
|
|
</p>
|
|
|
|
<!-- --- end subexercise --- -->
|
|
|
|
<!-- --- begin subexercise --- -->
|
|
<p>
|
|
<b>b)</b>
|
|
Write thereafter (using either <b>scikit-learn</b> or your matrix inversion code using for example <b>numpy</b>)
|
|
and perform an ordinary least squares fitting and compute the mean squared error for the training data and the test data. These calculations should apply to a model given by a fifth-order polynomial.
|
|
</p>
|
|
|
|
<!-- --- end subexercise --- -->
|
|
|
|
<!-- --- begin subexercise --- -->
|
|
<p>
|
|
<b>c)</b>
|
|
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 for the training and test data and plot both test and training data MSE 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)?
|
|
</p>
|
|
|
|
<!-- --- end subexercise --- -->
|
|
|
|
<!-- --- end exercise --- -->
|
|
<p>
|
|
<!-- navigation buttons at the bottom of the page -->
|
|
<ul class="pagination">
|
|
<li><a href="._week34-bs064.html">«</a></li>
|
|
<li><a href="._week34-bs000.html">1</a></li>
|
|
<li><a href="">...</a></li>
|
|
<li><a href="._week34-bs057.html">58</a></li>
|
|
<li><a href="._week34-bs058.html">59</a></li>
|
|
<li><a href="._week34-bs059.html">60</a></li>
|
|
<li><a href="._week34-bs060.html">61</a></li>
|
|
<li><a href="._week34-bs061.html">62</a></li>
|
|
<li><a href="._week34-bs062.html">63</a></li>
|
|
<li><a href="._week34-bs063.html">64</a></li>
|
|
<li><a href="._week34-bs064.html">65</a></li>
|
|
<li class="active"><a href="._week34-bs065.html">66</a></li>
|
|
</ul>
|
|
<!-- ------------------- end of main content --------------- -->
|
|
</div> <!-- end container -->
|
|
<!-- include javascript, jQuery *first* -->
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
|
<!-- Bootstrap footer
|
|
<footer>
|
|
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
|
</footer>
|
|
-->
|
|
<center style="font-size:80%">
|
|
<!-- copyright only on the titlepage -->
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|