850 lines
51 KiB
HTML
850 lines
51 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
|
||
<html lang="en" data-content_root="./" >
|
||
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>Project 1 on Machine Learning, deadline October 6 (midnight), 2025 — Applied Data Analysis and Machine Learning</title>
|
||
|
||
|
||
|
||
<script data-cfasync="false">
|
||
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
|
||
document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
|
||
</script>
|
||
|
||
<!-- Loaded before other Sphinx assets -->
|
||
<link href="_static/styles/theme.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
|
||
<link href="_static/styles/bootstrap.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
|
||
<link href="_static/styles/pydata-sphinx-theme.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
|
||
|
||
|
||
<link href="_static/vendor/fontawesome/6.5.2/css/all.min.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
|
||
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-solid-900.woff2" />
|
||
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-brands-400.woff2" />
|
||
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-regular-400.woff2" />
|
||
|
||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
|
||
<link rel="stylesheet" type="text/css" href="_static/styles/sphinx-book-theme.css?v=eba8b062" />
|
||
<link rel="stylesheet" type="text/css" href="_static/togglebutton.css?v=13237357" />
|
||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||
<link rel="stylesheet" type="text/css" href="_static/mystnb.8ecb98da25f57f5357bf6f572d296f466b2cfe2517ffebfabe82451661e28f02.css?v=6644e6bb" />
|
||
<link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css?v=4fa983c6" />
|
||
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
|
||
|
||
<!-- Pre-loaded scripts that we'll load fully later -->
|
||
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
|
||
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=dfe6caa3a7d634c4db9b" />
|
||
<script src="_static/vendor/fontawesome/6.5.2/js/all.min.js?digest=dfe6caa3a7d634c4db9b"></script>
|
||
|
||
<script src="_static/documentation_options.js?v=9eb32ce0"></script>
|
||
<script src="_static/doctools.js?v=9a2dae69"></script>
|
||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
|
||
<script src="_static/copybutton.js?v=f281be69"></script>
|
||
<script src="_static/scripts/sphinx-book-theme.js?v=887ef09a"></script>
|
||
<script>let toggleHintShow = 'Click to show';</script>
|
||
<script>let toggleHintHide = 'Click to hide';</script>
|
||
<script>let toggleOpenOnPrint = 'true';</script>
|
||
<script src="_static/togglebutton.js?v=4a39c7ea"></script>
|
||
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
|
||
<script src="_static/design-tabs.js?v=f930bc37"></script>
|
||
<script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"; const thebe_selector = ".thebe,.cell"; const thebe_selector_input = "pre"; const thebe_selector_output = ".output, .cell_output"</script>
|
||
<script async="async" src="_static/sphinx-thebe.js?v=c100c467"></script>
|
||
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
|
||
<script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"; const thebe_selector = ".thebe,.cell"; const thebe_selector_input = "pre"; const thebe_selector_output = ".output, .cell_output"</script>
|
||
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
|
||
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||
<script>DOCUMENTATION_OPTIONS.pagename = 'project1';</script>
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="prev" title="Exercises week 39" href="exercisesweek39.html" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
<meta name="docsearch:language" content="en"/>
|
||
</head>
|
||
|
||
|
||
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
|
||
|
||
|
||
|
||
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
|
||
|
||
<div id="pst-scroll-pixel-helper"></div>
|
||
|
||
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
|
||
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
|
||
|
||
|
||
<input type="checkbox"
|
||
class="sidebar-toggle"
|
||
id="pst-primary-sidebar-checkbox"/>
|
||
<label class="overlay overlay-primary" for="pst-primary-sidebar-checkbox"></label>
|
||
|
||
<input type="checkbox"
|
||
class="sidebar-toggle"
|
||
id="pst-secondary-sidebar-checkbox"/>
|
||
<label class="overlay overlay-secondary" for="pst-secondary-sidebar-checkbox"></label>
|
||
|
||
<div class="search-button__wrapper">
|
||
<div class="search-button__overlay"></div>
|
||
<div class="search-button__search-container">
|
||
<form class="bd-search d-flex align-items-center"
|
||
action="search.html"
|
||
method="get">
|
||
<i class="fa-solid fa-magnifying-glass"></i>
|
||
<input type="search"
|
||
class="form-control"
|
||
name="q"
|
||
id="search-input"
|
||
placeholder="Search this book..."
|
||
aria-label="Search this book..."
|
||
autocomplete="off"
|
||
autocorrect="off"
|
||
autocapitalize="off"
|
||
spellcheck="false"/>
|
||
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
|
||
</form></div>
|
||
</div>
|
||
|
||
<div class="pst-async-banner-revealer d-none">
|
||
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
|
||
</div>
|
||
|
||
|
||
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
|
||
</header>
|
||
|
||
|
||
<div class="bd-container">
|
||
<div class="bd-container__inner bd-page-width">
|
||
|
||
|
||
|
||
<div class="bd-sidebar-primary bd-sidebar">
|
||
|
||
|
||
|
||
<div class="sidebar-header-items sidebar-primary__section">
|
||
|
||
|
||
|
||
|
||
</div>
|
||
|
||
<div class="sidebar-primary-items__start sidebar-primary__section">
|
||
<div class="sidebar-primary-item">
|
||
|
||
|
||
|
||
|
||
|
||
<a class="navbar-brand logo" href="intro.html">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<img src="_static/logo.png" class="logo__image only-light" alt="Applied Data Analysis and Machine Learning - Home"/>
|
||
<script>document.write(`<img src="_static/logo.png" class="logo__image only-dark" alt="Applied Data Analysis and Machine Learning - Home"/>`);</script>
|
||
|
||
|
||
</a></div>
|
||
<div class="sidebar-primary-item">
|
||
|
||
<script>
|
||
document.write(`
|
||
<button class="btn search-button-field search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="fa-solid fa-magnifying-glass"></i>
|
||
<span class="search-button__default-text">Search</span>
|
||
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
|
||
</button>
|
||
`);
|
||
</script></div>
|
||
<div class="sidebar-primary-item"><nav class="bd-links bd-docs-nav" aria-label="Main">
|
||
<div class="bd-toc-item navbar-nav active">
|
||
|
||
<ul class="nav bd-sidenav bd-sidenav__home-link">
|
||
<li class="toctree-l1">
|
||
<a class="reference internal" href="intro.html">
|
||
Applied Data Analysis and Machine Learning
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">About the course</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="schedule.html">Course setting</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="teachers.html">Teachers and Grading</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="textbooks.html">Textbooks</a></li>
|
||
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Review of Statistics with Resampling Techniques and Linear Algebra</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="statistics.html">1. Elements of Probability Theory and Statistical Data Analysis</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="linalg.html">2. Linear Algebra, Handling of Arrays and more Python Features</a></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">From Regression to Support Vector Machines</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter1.html">3. Linear Regression</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter2.html">4. Ridge and Lasso Regression</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter3.html">5. Resampling Methods</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter4.html">6. Logistic Regression</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapteroptimization.html">7. Optimization, the central part of any Machine Learning algortithm</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter5.html">8. Support Vector Machines, overarching aims</a></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Decision Trees, Ensemble Methods and Boosting</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter6.html">9. Decision trees, overarching aims</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter7.html">10. Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods</a></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Dimensionality Reduction</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter8.html">11. Basic ideas of the Principal Component Analysis (PCA)</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="clustering.html">12. Clustering and Unsupervised Learning</a></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Deep Learning Methods</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter9.html">13. Neural networks</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter10.html">14. Building a Feed Forward Neural Network</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter11.html">15. Solving Differential Equations with Deep Learning</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter12.html">16. Convolutional Neural Networks</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chapter13.html">17. Recurrent neural networks: Overarching view</a></li>
|
||
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Weekly material, notes and exercises</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek34.html">Exercises week 34</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="week34.html">Week 34: Introduction to the course, Logistics and Practicalities</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek35.html">Exercises week 35</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="week35.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek36.html">Exercises week 36</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="week36.html">Week 36: Linear Regression and Gradient descent</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek37.html">Exercises week 37</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="week37.html">Week 37: Gradient descent methods</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek38.html">Exercises week 38</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="exercisesweek39.html">Exercises week 39</a></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Projects</span></p>
|
||
<ul class="current nav bd-sidenav">
|
||
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Project 1 on Machine Learning, deadline October 6 (midnight), 2025</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</nav></div>
|
||
</div>
|
||
|
||
|
||
<div class="sidebar-primary-items__end sidebar-primary__section">
|
||
</div>
|
||
|
||
<div id="rtd-footer-container"></div>
|
||
|
||
|
||
</div>
|
||
|
||
<main id="main-content" class="bd-main" role="main">
|
||
|
||
|
||
|
||
<div class="sbt-scroll-pixel-helper"></div>
|
||
|
||
<div class="bd-content">
|
||
<div class="bd-article-container">
|
||
|
||
<div class="bd-header-article d-print-none">
|
||
<div class="header-article-items header-article__inner">
|
||
|
||
<div class="header-article-items__start">
|
||
|
||
<div class="header-article-item"><button class="sidebar-toggle primary-toggle btn btn-sm" title="Toggle primary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<span class="fa-solid fa-bars"></span>
|
||
</button></div>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="header-article-items__end">
|
||
|
||
<div class="header-article-item">
|
||
|
||
<div class="article-header-buttons">
|
||
|
||
|
||
|
||
|
||
|
||
<div class="dropdown dropdown-download-buttons">
|
||
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Download this page">
|
||
<i class="fas fa-download"></i>
|
||
</button>
|
||
<ul class="dropdown-menu">
|
||
|
||
|
||
|
||
<li><a href="_sources/project1.ipynb" target="_blank"
|
||
class="btn btn-sm btn-download-source-button dropdown-item"
|
||
title="Download source file"
|
||
data-bs-placement="left" data-bs-toggle="tooltip"
|
||
>
|
||
|
||
|
||
<span class="btn__icon-container">
|
||
<i class="fas fa-file"></i>
|
||
</span>
|
||
<span class="btn__text-container">.ipynb</span>
|
||
</a>
|
||
</li>
|
||
|
||
|
||
|
||
|
||
<li>
|
||
<button onclick="window.print()"
|
||
class="btn btn-sm btn-download-pdf-button dropdown-item"
|
||
title="Print to PDF"
|
||
data-bs-placement="left" data-bs-toggle="tooltip"
|
||
>
|
||
|
||
|
||
<span class="btn__icon-container">
|
||
<i class="fas fa-file-pdf"></i>
|
||
</span>
|
||
<span class="btn__text-container">.pdf</span>
|
||
</button>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<button onclick="toggleFullScreen()"
|
||
class="btn btn-sm btn-fullscreen-button"
|
||
title="Fullscreen mode"
|
||
data-bs-placement="bottom" data-bs-toggle="tooltip"
|
||
>
|
||
|
||
|
||
<span class="btn__icon-container">
|
||
<i class="fas fa-expand"></i>
|
||
</span>
|
||
|
||
</button>
|
||
|
||
|
||
|
||
<script>
|
||
document.write(`
|
||
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light"></i>
|
||
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark"></i>
|
||
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto"></i>
|
||
</button>
|
||
`);
|
||
</script>
|
||
|
||
|
||
<script>
|
||
document.write(`
|
||
<button class="btn btn-sm pst-navbar-icon search-button search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
|
||
</button>
|
||
`);
|
||
</script>
|
||
<button class="sidebar-toggle secondary-toggle btn btn-sm" title="Toggle secondary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<span class="fa-solid fa-list"></span>
|
||
</button>
|
||
</div></div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div id="jb-print-docs-body" class="onlyprint">
|
||
<h1>Project 1 on Machine Learning, deadline October 6 (midnight), 2025</h1>
|
||
<!-- Table of contents -->
|
||
<div id="print-main-content">
|
||
<div id="jb-print-toc">
|
||
|
||
<div>
|
||
<h2> Contents </h2>
|
||
</div>
|
||
<nav aria-label="Page">
|
||
<ul class="visible nav section-nav flex-column">
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools">Preamble: Note on writing reports, using reference material, AI and other tools</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#regression-analysis-and-resampling-methods">Regression analysis and resampling methods</a><ul class="nav section-nav flex-column">
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-a-ordinary-least-square-ols-for-the-runge-function">Part a : Ordinary Least Square (OLS) for the Runge function</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-b-adding-ridge-regression-for-the-runge-function">Part b: Adding Ridge regression for the Runge function</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-c-writing-your-own-gradient-descent-code">Part c: Writing your own gradient descent code</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate">Part d: Including momentum and more advanced ways to update the learning the rate</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-e-writing-our-own-code-for-lasso-regression">Part e: Writing our own code for Lasso regression</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-f-stochastic-gradient-descent">Part f: Stochastic gradient descent</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-g-bias-variance-trade-off-and-resampling-techniques">Part g: Bias-variance trade-off and resampling techniques</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-h-cross-validation-as-resampling-techniques-adding-more-complexity">Part h): Cross-validation as resampling techniques, adding more complexity</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#background-literature">Background literature</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#introduction-to-numerical-projects">Introduction to numerical projects</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#format-for-electronic-delivery-of-report-and-programs">Format for electronic delivery of report and programs</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#software-and-needed-installations">Software and needed installations</a></li>
|
||
</ul>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div id="searchbox"></div>
|
||
<article class="bd-article">
|
||
|
||
<!-- HTML file automatically generated from DocOnce source (https://github.com/doconce/doconce/)
|
||
doconce format html Project1.do.txt -->
|
||
<!-- dom:TITLE: Project 1 on Machine Learning, deadline October 6 (midnight), 2025 --><section class="tex2jax_ignore mathjax_ignore" id="project-1-on-machine-learning-deadline-october-6-midnight-2025">
|
||
<h1>Project 1 on Machine Learning, deadline October 6 (midnight), 2025<a class="headerlink" href="#project-1-on-machine-learning-deadline-october-6-midnight-2025" title="Link to this heading">#</a></h1>
|
||
<p><strong>Data Analysis and Machine Learning FYS-STK3155/FYS4155</strong>, University of Oslo, Norway</p>
|
||
<p>Date: <strong>September 2</strong></p>
|
||
<section id="preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools">
|
||
<h2>Preamble: Note on writing reports, using reference material, AI and other tools<a class="headerlink" href="#preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools" title="Link to this heading">#</a></h2>
|
||
<p>We want you to answer the three different projects by handing in
|
||
reports written like a standard scientific/technical report. The
|
||
links at
|
||
<a class="github reference external" href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Projects">CompPhysics/MachineLearning</a>
|
||
contain more information. There you can find examples of previous
|
||
reports, the projects themselves, how we grade reports etc. How to
|
||
write reports will also be discussed during the various lab
|
||
sessions. Please do ask us if you are in doubt.</p>
|
||
<p>When using codes and material from other sources, you should refer to
|
||
these in the bibliography of your report, indicating wherefrom you for
|
||
example got the code, whether this is from the lecture notes,
|
||
softwares like Scikit-Learn, TensorFlow, PyTorch or other sources. These sources
|
||
should always be cited correctly. How to cite some
|
||
of the libraries is often indicated from their corresponding GitHub
|
||
sites or websites, see for example how to cite Scikit-Learn at
|
||
<a class="reference external" href="https://scikit-learn.org/dev/about.html">https://scikit-learn.org/dev/about.html</a>.</p>
|
||
<p>We enocurage you to use tools like
|
||
<a class="reference external" href="https://openai.com/chatgpt/">ChatGPT</a> or similar in writing the report. If you use for example ChatGPT,
|
||
please do cite it properly and include (if possible) your questions and answers as an addition to the report. This can
|
||
be uploaded to for example your website, GitHub/GitLab or similar as supplemental material.</p>
|
||
<p>If you would like to study other data sets, feel free to propose other
|
||
sets. What we have proposed here are mere suggestions from our
|
||
side. If you opt for another data set, consider using a set which has
|
||
been studied in the scientific literature. This makes it easier for
|
||
you to compare and analyze your results. Comparing with existing
|
||
results from the scientific literature is also an essential element of
|
||
the scientific discussion. The University of California at Irvine
|
||
with its Machine Learning repository at
|
||
<a class="reference external" href="https://archive.ics.uci.edu/ml/index.php">https://archive.ics.uci.edu/ml/index.php</a> is an excellent site to
|
||
look up for examples and
|
||
inspiration. <a class="reference external" href="https://www.kaggle.com/">Kaggle.com</a> is an equally
|
||
interesting site. Feel free to explore these sites. When selecting
|
||
other data sets, make sure these are sets used for regression problems
|
||
(not classification).</p>
|
||
</section>
|
||
<section id="regression-analysis-and-resampling-methods">
|
||
<h2>Regression analysis and resampling methods<a class="headerlink" href="#regression-analysis-and-resampling-methods" title="Link to this heading">#</a></h2>
|
||
<p>The main aim of this project is to study in more detail various
|
||
regression methods, including Ordinary Least Squares (OLS) reegression, Ridge regression and LASSO regression.
|
||
In addition to the scientific part, in this course we want also to
|
||
give you an experience in writing scientific reports.</p>
|
||
<p>We will study how to fit polynomials to specific
|
||
one-dimensional functions (feel free to replace the suggested function with more complicated ones).</p>
|
||
<p>We will use Runge’s function (see <a class="reference external" href="https://en.wikipedia.org/wiki/Runge%27s_phenomenon">https://en.wikipedia.org/wiki/Runge’s_phenomenon</a> for a discussion). The one-dimensional function we will study is</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
f(x) = \frac{1}{1+25x^2}.
|
||
\]</div>
|
||
<p>Our first step will be to perform an OLS regression analysis of this
|
||
function, trying out a polynomial fit with an <span class="math notranslate nohighlight">\(x\)</span> dependence of the
|
||
form <span class="math notranslate nohighlight">\([x,x^2,\dots]\)</span>. You can use a uniform distribution to set up the
|
||
arrays of values for <span class="math notranslate nohighlight">\(x \in [-1,1]\)</span>, or alternatively use a fixed step size.
|
||
Thereafter we will repeat many of the same steps when using the Ridge and Lasso regression methods,
|
||
introducing thereby a dependence on the hyperparameter (penalty) <span class="math notranslate nohighlight">\(\lambda\)</span>.</p>
|
||
<p>We will also include bootstrap as a resampling technique in order to
|
||
study the so-called <strong>bias-variance tradeoff</strong>. After that we will
|
||
include the so-called cross-validation technique.</p>
|
||
<section id="part-a-ordinary-least-square-ols-for-the-runge-function">
|
||
<h3>Part a : Ordinary Least Square (OLS) for the Runge function<a class="headerlink" href="#part-a-ordinary-least-square-ols-for-the-runge-function" title="Link to this heading">#</a></h3>
|
||
<p>We will generate our own dataset for abovementioned function
|
||
<span class="math notranslate nohighlight">\(\mathrm{Runge}(x)\)</span> function with <span class="math notranslate nohighlight">\(x\in [-1,1]\)</span>. You should explore also the addition
|
||
of an added stochastic noise to this function using the normal
|
||
distribution <span class="math notranslate nohighlight">\(N(0,1)\)</span>.</p>
|
||
<p><em>Write your own code</em> (using for example the pseudoinverse function <strong>pinv</strong> from <strong>Numpy</strong> ) and perform a standard <strong>ordinary least square regression</strong>
|
||
analysis using polynomials in <span class="math notranslate nohighlight">\(x\)</span> up to order <span class="math notranslate nohighlight">\(15\)</span> or higher. Explore the dependence on the number of data points and the polynomial degree.</p>
|
||
<p>Evaluate the mean Squared error (MSE)</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
MSE(\boldsymbol{y},\tilde{\boldsymbol{y}}) = \frac{1}{n}
|
||
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
|
||
\]</div>
|
||
<p>and the <span class="math notranslate nohighlight">\(R^2\)</span> score function. If <span class="math notranslate nohighlight">\(\tilde{\boldsymbol{y}}_i\)</span> is the predicted
|
||
value of the <span class="math notranslate nohighlight">\(i-th\)</span> sample and <span class="math notranslate nohighlight">\(y_i\)</span> is the corresponding true value,
|
||
then the score <span class="math notranslate nohighlight">\(R^2\)</span> is defined as</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
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},
|
||
\]</div>
|
||
<p>where we have defined the mean value of <span class="math notranslate nohighlight">\(\boldsymbol{y}\)</span> as</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
|
||
\]</div>
|
||
<p>Plot the resulting scores (MSE and R<span class="math notranslate nohighlight">\(^2\)</span>) as functions of the polynomial degree (here up to polymial degree 15).
|
||
Plot also the parameters <span class="math notranslate nohighlight">\(\theta\)</span> as you increase the order of the polynomial. Comment your results.</p>
|
||
<p>Your code has to include a scaling/centering of the data (for example by
|
||
subtracting the mean value), and
|
||
a split of the data in training and test data. For the scaling you can
|
||
either write your own code or use for example the function for
|
||
splitting training data provided by the library <strong>Scikit-Learn</strong> (make
|
||
sure you have installed it). This function is called
|
||
<span class="math notranslate nohighlight">\(train\_test\_split\)</span>. <strong>You should present a critical discussion of why and how you have scaled or not scaled the data</strong>.</p>
|
||
<p>It is normal in essentially all Machine Learning studies to split the
|
||
data in a training set and a test set (eventually also an additional
|
||
validation set). There
|
||
is no explicit recipe for how much data should be included as training
|
||
data and say test data. An accepted rule of thumb is to use
|
||
approximately <span class="math notranslate nohighlight">\(2/3\)</span> to <span class="math notranslate nohighlight">\(4/5\)</span> of the data as training data.</p>
|
||
<p>You can easily reuse the solutions to your exercises from week 35.
|
||
See also the lecture slides from week 35 and week 36.</p>
|
||
<p>On scaling, we recommend reading the following section from the scikit-learn software description, see <a class="reference external" href="https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html#plot-all-scaling-standard-scaler-section">https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html#plot-all-scaling-standard-scaler-section</a>.</p>
|
||
</section>
|
||
<section id="part-b-adding-ridge-regression-for-the-runge-function">
|
||
<h3>Part b: Adding Ridge regression for the Runge function<a class="headerlink" href="#part-b-adding-ridge-regression-for-the-runge-function" title="Link to this heading">#</a></h3>
|
||
<p>Write your own code for the Ridge method as done in the previous
|
||
exercise. The lecture notes from week 35 and 36 contain more information. Furthermore, the results from the exercise set from week 36 is something you can reuse here.</p>
|
||
<p>Perform the same analysis as you did in the previous exercise but now for different values of <span class="math notranslate nohighlight">\(\lambda\)</span>. Compare and
|
||
analyze your results with those obtained in part a) with the OLS method. Study the
|
||
dependence on <span class="math notranslate nohighlight">\(\lambda\)</span>.</p>
|
||
</section>
|
||
<section id="part-c-writing-your-own-gradient-descent-code">
|
||
<h3>Part c: Writing your own gradient descent code<a class="headerlink" href="#part-c-writing-your-own-gradient-descent-code" title="Link to this heading">#</a></h3>
|
||
<p>Replace now the analytical expressions for the optimal parameters
|
||
<span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span> with your own gradient descent code. In this exercise we
|
||
focus only on the simplest gradient descent approach with a fixed
|
||
learning rate (see the exercises from week 37 and the lecture notes
|
||
from week 36).</p>
|
||
<p>Study and compare your results from parts a) and b) with your gradient
|
||
descent approch. Discuss in particular the role of the learning rate.</p>
|
||
</section>
|
||
<section id="part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate">
|
||
<h3>Part d: Including momentum and more advanced ways to update the learning the rate<a class="headerlink" href="#part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate" title="Link to this heading">#</a></h3>
|
||
<p>We keep our focus on OLS and Ridge regression and update our code for
|
||
the gradient descent method by including <strong>momentum</strong>, <strong>ADAgrad</strong>,
|
||
<strong>RMSprop</strong> and <strong>ADAM</strong> as methods fro iteratively updating your learning
|
||
rate. Discuss the results and compare the different methods applied to
|
||
the one-dimensional Runge function. The lecture notes from week 37 contain several examples on how to implement these methods.</p>
|
||
</section>
|
||
<section id="part-e-writing-our-own-code-for-lasso-regression">
|
||
<h3>Part e: Writing our own code for Lasso regression<a class="headerlink" href="#part-e-writing-our-own-code-for-lasso-regression" title="Link to this heading">#</a></h3>
|
||
<p>LASSO regression (see lecture slides from week 36 and week 37)
|
||
represents our first encounter with a machine learning method which
|
||
cannot be solved through analytical expressions (as in OLS and Ridge regression). Use the gradient
|
||
descent methods you developed in parts c) and d) to solve the LASSO
|
||
optimization problem. You can compare your results with
|
||
the functionalities of <strong>Scikit-Learn</strong>.</p>
|
||
<p>Discuss (critically) your results for the Runge function from OLS,
|
||
Ridge and LASSO regression using the various gradient descent
|
||
approaches.</p>
|
||
</section>
|
||
<section id="part-f-stochastic-gradient-descent">
|
||
<h3>Part f: Stochastic gradient descent<a class="headerlink" href="#part-f-stochastic-gradient-descent" title="Link to this heading">#</a></h3>
|
||
<p>Our last gradient step is to include stochastic gradient descent using
|
||
the same methods to update the learning rates as in parts c-e).
|
||
Compare and discuss your results with and without stochastic gradient
|
||
and give a critical assessment of the various methods.</p>
|
||
</section>
|
||
<section id="part-g-bias-variance-trade-off-and-resampling-techniques">
|
||
<h3>Part g: Bias-variance trade-off and resampling techniques<a class="headerlink" href="#part-g-bias-variance-trade-off-and-resampling-techniques" title="Link to this heading">#</a></h3>
|
||
<p>Our aim here is to study the bias-variance trade-off by implementing
|
||
the <strong>bootstrap</strong> resampling technique. <strong>We will only use the simpler
|
||
ordinary least squares here</strong>.</p>
|
||
<p>With a code which does OLS and includes resampling techniques,
|
||
we will now discuss the bias-variance trade-off in the context of
|
||
continuous predictions such as regression. However, many of the
|
||
intuitions and ideas discussed here also carry over to classification
|
||
tasks and basically all Machine Learning algorithms.</p>
|
||
<p>Before you perform an analysis of the bias-variance trade-off on your
|
||
test data, make first a figure similar to Fig. 2.11 of Hastie,
|
||
Tibshirani, and Friedman. Figure 2.11 of this reference displays only
|
||
the test and training MSEs. The test MSE can be used to indicate
|
||
possible regions of low/high bias and variance. You will most likely
|
||
not get an equally smooth curve! You may also need to increase the
|
||
polynomial order and play around with the number of data points as
|
||
well (see also the exercise set from week 35).</p>
|
||
<p>With this result we move on to the bias-variance trade-off analysis.</p>
|
||
<p>Consider a
|
||
dataset <span class="math notranslate nohighlight">\(\mathcal{L}\)</span> consisting of the data
|
||
<span class="math notranslate nohighlight">\(\mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\}\)</span>.</p>
|
||
<p>We assume that the true data is generated from a noisy model</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon}.
|
||
\]</div>
|
||
<p>Here <span class="math notranslate nohighlight">\(\epsilon\)</span> is normally distributed with mean zero and standard
|
||
deviation <span class="math notranslate nohighlight">\(\sigma^2\)</span>.</p>
|
||
<p>In our derivation of the ordinary least squares method we defined then
|
||
an approximation to the function <span class="math notranslate nohighlight">\(f\)</span> in terms of the parameters
|
||
<span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span> and the design matrix <span class="math notranslate nohighlight">\(\boldsymbol{X}\)</span> which embody our model,
|
||
that is <span class="math notranslate nohighlight">\(\boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\theta}\)</span>.</p>
|
||
<p>The parameters <span class="math notranslate nohighlight">\(\boldsymbol{\theta}\)</span> are in turn found by optimizing the mean
|
||
squared error via the so-called cost function</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
C(\boldsymbol{X},\boldsymbol{\theta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right].
|
||
\]</div>
|
||
<p>Here the expected value <span class="math notranslate nohighlight">\(\mathbb{E}\)</span> is the sample value.</p>
|
||
<p>Show that you can rewrite this in terms of a term which contains the
|
||
variance of the model itself (the so-called variance term), a term
|
||
which measures the deviation from the true data and the mean value of
|
||
the model (the bias term) and finally the variance of the noise.</p>
|
||
<p>That is, show that</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathrm{Bias}[\tilde{y}]+\mathrm{var}[\tilde{y}]+\sigma^2,
|
||
\]</div>
|
||
<p>with (we approximate <span class="math notranslate nohighlight">\(f(\boldsymbol{x})\approx \boldsymbol{y}\)</span>)</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
\mathrm{Bias}[\tilde{y}]=\mathbb{E}\left[\left(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]\right)^2\right],
|
||
\]</div>
|
||
<p>and</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[
|
||
\mathrm{var}[\tilde{y}]=\mathbb{E}\left[\left(\tilde{\boldsymbol{y}}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]\right)^2\right]=\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2.
|
||
\]</div>
|
||
<p><strong>Important note</strong>: Since the function <span class="math notranslate nohighlight">\(f(x)\)</span> is unknown, in order to be able to evalute the bias, we replace <span class="math notranslate nohighlight">\(f(\boldsymbol{x})\)</span> in the expression for the bias with <span class="math notranslate nohighlight">\(\boldsymbol{y}\)</span>.</p>
|
||
<p>The answer to this exercise should be included in the theory part of
|
||
the report. This exercise is also part of the weekly exercises of
|
||
week 38. Explain what the terms mean and discuss their
|
||
interpretations.</p>
|
||
<p>Perform then a bias-variance analysis of the Runge function by
|
||
studying the MSE value as function of the complexity of your model.</p>
|
||
<p>Discuss the bias and variance trade-off as function
|
||
of your model complexity (the degree of the polynomial) and the number
|
||
of data points, and possibly also your training and test data using the <strong>bootstrap</strong> resampling method.
|
||
You can follow the code example in the jupyter-book at <a class="reference external" href="https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/chapter3.html#the-bias-variance-tradeoff">https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/chapter3.html#the-bias-variance-tradeoff</a>.</p>
|
||
</section>
|
||
<section id="part-h-cross-validation-as-resampling-techniques-adding-more-complexity">
|
||
<h3>Part h): Cross-validation as resampling techniques, adding more complexity<a class="headerlink" href="#part-h-cross-validation-as-resampling-techniques-adding-more-complexity" title="Link to this heading">#</a></h3>
|
||
<p>The aim here is to implement another widely popular
|
||
resampling technique, the so-called cross-validation method.</p>
|
||
<p>Implement the <span class="math notranslate nohighlight">\(k\)</span>-fold cross-validation algorithm (feel free to use
|
||
the functionality of <strong>Scikit-Learn</strong> or write your own code) and
|
||
evaluate again the MSE function resulting from the test folds.</p>
|
||
<p>Compare the MSE you get from your cross-validation code with the one
|
||
you got from your <strong>bootstrap</strong> code from the previous exercise. Comment and interpret your results.</p>
|
||
<p>In addition to using the ordinary least squares method, you should
|
||
include both Ridge and Lasso regression in the final analysis.</p>
|
||
</section>
|
||
</section>
|
||
<section id="background-literature">
|
||
<h2>Background literature<a class="headerlink" href="#background-literature" title="Link to this heading">#</a></h2>
|
||
<ol class="arabic simple">
|
||
<li><p>For a discussion and derivation of the variances and mean squared errors using linear regression, see the <a class="reference external" href="https://arxiv.org/abs/1509.09169">Lecture notes on ridge regression by Wessel N. van Wieringen</a></p></li>
|
||
<li><p>The textbook of <a class="reference external" href="https://www.springer.com/gp/book/9780387848570">Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer</a>, chapters 3 and 7 are the most relevant ones for the analysis of parts g) and h).</p></li>
|
||
</ol>
|
||
</section>
|
||
<section id="introduction-to-numerical-projects">
|
||
<h2>Introduction to numerical projects<a class="headerlink" href="#introduction-to-numerical-projects" title="Link to this heading">#</a></h2>
|
||
<p>Here follows a brief recipe and recommendation on how to answer the various questions when preparing your answers.</p>
|
||
<ul class="simple">
|
||
<li><p>Give a short description of the nature of the problem and the eventual numerical methods you have used.</p></li>
|
||
<li><p>Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.</p></li>
|
||
<li><p>Include the source code of your program. Comment your program properly. You should have the code at your GitHub/GitLab link. You can also place the code in an appendix of your report.</p></li>
|
||
<li><p>If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.</p></li>
|
||
<li><p>Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.</p></li>
|
||
<li><p>Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.</p></li>
|
||
<li><p>Try to give an interpretation of you results in your answers to the problems.</p></li>
|
||
<li><p>Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you’ve made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.</p></li>
|
||
<li><p>Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don’t properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="format-for-electronic-delivery-of-report-and-programs">
|
||
<h2>Format for electronic delivery of report and programs<a class="headerlink" href="#format-for-electronic-delivery-of-report-and-programs" title="Link to this heading">#</a></h2>
|
||
<p>The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008, Julia or Python. The following prescription should be followed when preparing the report:</p>
|
||
<ul class="simple">
|
||
<li><p>Use Canvas to hand in your projects, log in at <a class="reference external" href="https://www.uio.no/english/services/it/education/canvas/">https://www.uio.no/english/services/it/education/canvas/</a> with your normal UiO username and password.</p></li>
|
||
<li><p>Upload <strong>only</strong> the report file or the link to your GitHub/GitLab or similar typo of repos! For the source code file(s) you have developed please provide us with your link to your GitHub/GitLab or similar domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them.</p></li>
|
||
<li><p>In your GitHub/GitLab or similar repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters.</p></li>
|
||
</ul>
|
||
<p>Finally,
|
||
we encourage you to collaborate. Optimal working groups consist of
|
||
2-3 students. You can then hand in a common report.</p>
|
||
</section>
|
||
<section id="software-and-needed-installations">
|
||
<h2>Software and needed installations<a class="headerlink" href="#software-and-needed-installations" title="Link to this heading">#</a></h2>
|
||
<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 <strong>pip</strong> as</p>
|
||
<ol class="arabic simple">
|
||
<li><p>pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow</p></li>
|
||
</ol>
|
||
<p>For Python3, replace <strong>pip</strong> with <strong>pip3</strong>.</p>
|
||
<p>See below for a discussion of <strong>tensorflow</strong> and <strong>scikit-learn</strong>.</p>
|
||
<p>For OSX users we recommend also, after having installed Xcode, to install <strong>brew</strong>. Brew allows
|
||
for a seamless installation of additional software via for example</p>
|
||
<ol class="arabic simple">
|
||
<li><p>brew install python3</p></li>
|
||
</ol>
|
||
<p>For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution
|
||
you can use <strong>pip</strong> as well and simply install Python as</p>
|
||
<ol class="arabic simple">
|
||
<li><p>sudo apt-get install python3 (or python for python2.7)</p></li>
|
||
</ol>
|
||
<p>etc etc.</p>
|
||
<p>If you don’t want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely</p>
|
||
<ol class="arabic simple">
|
||
<li><p><a class="reference external" href="https://docs.anaconda.com/">Anaconda</a> Anaconda 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 <strong>conda</strong></p></li>
|
||
<li><p><a class="reference external" href="https://www.enthought.com/product/canopy/">Enthought canopy</a> is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.</p></li>
|
||
</ol>
|
||
<p>Popular software packages written in Python for ML are</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference external" href="http://scikit-learn.org/stable/">Scikit-learn</a>,</p></li>
|
||
<li><p><a class="reference external" href="https://www.tensorflow.org/">Tensorflow</a>,</p></li>
|
||
<li><p><a class="reference external" href="http://pytorch.org/">PyTorch</a> and</p></li>
|
||
<li><p><a class="reference external" href="https://keras.io/">Keras</a>.</p></li>
|
||
</ul>
|
||
<p>These are all freely available at their respective GitHub sites. They
|
||
encompass communities of developers in the thousands or more. And the number
|
||
of code developers and contributors keeps increasing.</p>
|
||
</section>
|
||
</section>
|
||
|
||
<script type="text/x-thebe-config">
|
||
{
|
||
requestKernel: true,
|
||
binderOptions: {
|
||
repo: "binder-examples/jupyter-stacks-datascience",
|
||
ref: "master",
|
||
},
|
||
codeMirrorConfig: {
|
||
theme: "abcdef",
|
||
mode: "python"
|
||
},
|
||
kernelOptions: {
|
||
name: "python3",
|
||
path: "./."
|
||
},
|
||
predefinedOutput: true
|
||
}
|
||
</script>
|
||
<script>kernelName = 'python3'</script>
|
||
|
||
</article>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<footer class="prev-next-footer d-print-none">
|
||
|
||
<div class="prev-next-area">
|
||
<a class="left-prev"
|
||
href="exercisesweek39.html"
|
||
title="previous page">
|
||
<i class="fa-solid fa-angle-left"></i>
|
||
<div class="prev-next-info">
|
||
<p class="prev-next-subtitle">previous</p>
|
||
<p class="prev-next-title">Exercises week 39</p>
|
||
</div>
|
||
</a>
|
||
</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<div class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">
|
||
|
||
|
||
<div class="sidebar-secondary-item">
|
||
<div class="page-toc tocsection onthispage">
|
||
<i class="fa-solid fa-list"></i> Contents
|
||
</div>
|
||
<nav class="bd-toc-nav page-toc">
|
||
<ul class="visible nav section-nav flex-column">
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools">Preamble: Note on writing reports, using reference material, AI and other tools</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#regression-analysis-and-resampling-methods">Regression analysis and resampling methods</a><ul class="nav section-nav flex-column">
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-a-ordinary-least-square-ols-for-the-runge-function">Part a : Ordinary Least Square (OLS) for the Runge function</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-b-adding-ridge-regression-for-the-runge-function">Part b: Adding Ridge regression for the Runge function</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-c-writing-your-own-gradient-descent-code">Part c: Writing your own gradient descent code</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate">Part d: Including momentum and more advanced ways to update the learning the rate</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-e-writing-our-own-code-for-lasso-regression">Part e: Writing our own code for Lasso regression</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-f-stochastic-gradient-descent">Part f: Stochastic gradient descent</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-g-bias-variance-trade-off-and-resampling-techniques">Part g: Bias-variance trade-off and resampling techniques</a></li>
|
||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#part-h-cross-validation-as-resampling-techniques-adding-more-complexity">Part h): Cross-validation as resampling techniques, adding more complexity</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#background-literature">Background literature</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#introduction-to-numerical-projects">Introduction to numerical projects</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#format-for-electronic-delivery-of-report-and-programs">Format for electronic delivery of report and programs</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#software-and-needed-installations">Software and needed installations</a></li>
|
||
</ul>
|
||
</nav></div>
|
||
|
||
</div></div>
|
||
|
||
|
||
</div>
|
||
<footer class="bd-footer-content">
|
||
|
||
<div class="bd-footer-content__inner container">
|
||
|
||
<div class="footer-item">
|
||
|
||
<p class="component-author">
|
||
By Morten Hjorth-Jensen
|
||
</p>
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
|
||
<p class="copyright">
|
||
|
||
© Copyright 2023.
|
||
<br/>
|
||
|
||
</p>
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</footer>
|
||
|
||
|
||
</main>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Scripts loaded after <body> so the DOM is not blocked -->
|
||
<script src="_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b"></script>
|
||
<script src="_static/scripts/pydata-sphinx-theme.js?digest=dfe6caa3a7d634c4db9b"></script>
|
||
|
||
<footer class="bd-footer">
|
||
</footer>
|
||
</body>
|
||
</html> |