Skip to content

Commit

Permalink
deploy: e68e7c9
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanTodoran committed Oct 30, 2023
1 parent 38c94c9 commit 5389cbb
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 294 deletions.
82 changes: 0 additions & 82 deletions Chapter3-MachineLearning/3.3_binary_classification.html
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/3.3_binary_classification_5_0.png" src="../_images/3.3_binary_classification_5_0.png" />
</div>
</div>
<p>We will start with the fundamental LDA.</p>
<div class="cell docutils container">
Expand All @@ -730,11 +727,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>The mean accuracy on the given test and labels is 0.875000
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand All @@ -746,12 +738,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x7f7c5ef8fdf0&gt;
</pre></div>
</div>
<img alt="../_images/3.3_binary_classification_8_1.png" src="../_images/3.3_binary_classification_8_1.png" />
</div>
</div>
<p>The results shows a not-too bad classification, but a low confidence.</p>
<p>Let’s try a different classifer: KNN</p>
Expand All @@ -776,15 +762,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>The mean accuracy on the given test and labels is 0.975000
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x7f7c5ad06230&gt;
</pre></div>
</div>
<img alt="../_images/3.3_binary_classification_10_2.png" src="../_images/3.3_binary_classification_10_2.png" />
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand All @@ -795,12 +772,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x7f7c5ab6c760&gt;
</pre></div>
</div>
<img alt="../_images/3.3_binary_classification_11_1.png" src="../_images/3.3_binary_classification_11_1.png" />
</div>
</div>
<p>Now we will test to see what happens when you do not <strong>normalize</strong> your data before the classification. We will stretch the first axis of the data to see the effects.</p>
<div class="cell docutils container">
Expand Down Expand Up @@ -835,15 +806,6 @@ <h2>1.1 Synthetic Data<a class="headerlink" href="#synthetic-data" title="Permal
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>The mean accuracy on the given test and labels is 0.775000
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x7f7c5ace6590&gt;
</pre></div>
</div>
<img alt="../_images/3.3_binary_classification_14_2.png" src="../_images/3.3_binary_classification_14_2.png" />
</div>
</div>
<p>This drastically reduces the performance.</p>
</section>
Expand Down Expand Up @@ -927,17 +889,6 @@ <h2>2. Classifier Performance Metrics<a class="headerlink" href="#classifier-per
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>confusion matrix
[[18 1]
[ 0 21]]
precison, recall
0.9545454545454546 1.0
F1 score
0.9767441860465117
</pre></div>
</div>
</div>
</div>
<p>A complete well-formatted report of the performance can be called using the function <code class="docutils literal notranslate"><span class="pre">classification_report</span></code>:</p>
<div class="cell docutils container">
Expand All @@ -948,19 +899,6 @@ <h2>2. Classifier Performance Metrics<a class="headerlink" href="#classifier-per
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Classification report for classifier KNeighborsClassifier():
precision recall f1-score support

0 1.00 0.95 0.97 19
1 0.95 1.00 0.98 21

accuracy 0.97 40
macro avg 0.98 0.97 0.97 40
weighted avg 0.98 0.97 0.97 40
</pre></div>
</div>
</div>
</div>
<p><strong>Precision and recall trade off</strong>: increasing precision reduces recall.</p>
<p><span class="math notranslate nohighlight">\(precision = \frac{TP}{TP+FP}\)</span></p>
Expand All @@ -986,12 +924,6 @@ <h2>2. Classifier Performance Metrics<a class="headerlink" href="#classifier-per
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x15225a3a0&gt;]
</pre></div>
</div>
<img alt="../_images/3.3_binary_classification_21_1.png" src="../_images/3.3_binary_classification_21_1.png" />
</div>
</div>
<p>We now explore the different classifiers packaged in scikit learn. We can systematically test their performance and save the precision, recall,</p>
<div class="cell docutils container">
Expand Down Expand Up @@ -1051,20 +983,6 @@ <h2>3. Model exploration<a class="headerlink" href="#model-exploration" title="P
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> CLF name precision recall f1_score
0 Nearest Neighbors 0.954545 1.000000 0.976744
1 Linear SVM 0.900000 0.857143 0.878049
2 RBF SVM 0.954545 1.000000 0.976744
3 Gaussian Process 0.954545 1.000000 0.976744
4 Decision Tree 0.913043 1.000000 0.954545
5 Random Forest 0.952381 0.952381 0.952381
6 AdaBoost 0.950000 0.904762 0.926829
7 Naive Bayes 0.900000 0.857143 0.878049
8 QDA 0.857143 0.857143 0.857143
</pre></div>
</div>
</div>
</div>
</section>
</section>
Expand Down
Binary file removed _images/3.3_binary_classification_10_2.png
Binary file not shown.
Binary file removed _images/3.3_binary_classification_11_1.png
Binary file not shown.
Binary file removed _images/3.3_binary_classification_14_2.png
Binary file not shown.
Binary file removed _images/3.3_binary_classification_21_1.png
Binary file not shown.
Binary file removed _images/3.3_binary_classification_5_0.png
Binary file not shown.
Binary file removed _images/3.3_binary_classification_8_1.png
Binary file not shown.
235 changes: 24 additions & 211 deletions _sources/Chapter3-MachineLearning/3.3_binary_classification.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 5389cbb

Please sign in to comment.