Revised first two weeks from feedback

This commit is contained in:
KarlHenrik
2025-08-13 12:54:12 +02:00
parent 3425395c86
commit f88eefcf7a
16 changed files with 89 additions and 140 deletions
+4 -2
View File
@@ -446,7 +446,7 @@ document.write(`
<h2>Exercise 3 - Setting up a Python virtual environment<a class="headerlink" href="#exercise-3-setting-up-a-python-virtual-environment" title="Link to this heading">#</a></h2>
<p>Following the theme of the previous exercises, another way of improving the reproducibility of your results and shareability of your code is having a good handle on which python packages you are using.</p>
<p>There are many ways to manage your packages in Python, and you are free to use any approach you want, but in this course we encourage you to use something called a virtual environment. A virtual environemnt is a folder in your project which contains a Python runtime executable as well as all the packages you are using in the current project. In this way, each of your projects has its required set of packages installed in the same folder, so that if anything goes wrong while managing your packages it only affects the one project, and if multiple projects require different versions of the same package, you dont need to worry about messing up old projects. Also, its easy to just delete the folder and start over if anything goes wrong.</p>
<p>Virtual environments are typically created, activated, managed and updated using terminal commands, but for now we recommend that you let VS Code handle it for you to make the coding experience much easier.</p>
<p>Virtual environments are typically created, activated, managed and updated using terminal commands, but for now we recommend that you let VS Code handle it for you to make the coding experience much easier. If you are familiar with another approach for virtual environments that works for you, feel free to keep doing it that way.</p>
<p><strong>a)</strong> Open this notebook in VS Code (<a class="reference external" href="https://code.visualstudio.com/Download">https://code.visualstudio.com/Download</a>). Download the Python and Jupyter extensions.</p>
<p><strong>b)</strong> Press ´Cmd + Shift + P´, then search and run ´Python: Create Environment…´</p>
<p><strong>c)</strong> Select ´Venv´</p>
@@ -483,10 +483,12 @@ document.write(`
<span class="n">line_model</span> <span class="o">=</span> <span class="n">LinearRegression</span><span class="p">()</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">line_predict</span> <span class="o">=</span> <span class="n">line_model</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="c1">#line_mse = ...</span>
<span class="c1">#poly_features = ...</span>
<span class="c1">#poly_model = LinearRegression().fit(..., y)</span>
<span class="c1">#poly_predict = ...</span>
<span class="c1">#poly_mse = ...</span>
<span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;Data&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">line_predict</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;Line model&quot;</span><span class="p">)</span>
@@ -496,7 +498,7 @@ document.write(`
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/fbd74da3fcd21613c4c425622594644bbfe45b6a7fd50ac62da4e3136a737128.png" src="_images/fbd74da3fcd21613c4c425622594644bbfe45b6a7fd50ac62da4e3136a737128.png" />
<img alt="_images/c62786c19b580c6638248aa3cfe7dea30bdbc00a922e7e45a45a5a7a053bdb38.png" src="_images/c62786c19b580c6638248aa3cfe7dea30bdbc00a922e7e45a45a5a7a053bdb38.png" />
</div>
</div>
</section>