<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Supervisedlearning on davethehuman.com</title><link>https://davethehuman.com/tags/supervisedlearning/</link><description>Recent content in Supervisedlearning on davethehuman.com</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Dave the human</copyright><lastBuildDate>Mon, 12 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://davethehuman.com/tags/supervisedlearning/index.xml" rel="self" type="application/rss+xml"/><item><title>KNN from scratch</title><link>https://davethehuman.com/notes/knn-from-scratch/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/knn-from-scratch/</guid><description>&lt;h2 class="relative group"&gt;Algorithm and implementation
 &lt;div id="algorithm-and-implementation" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#algorithm-and-implementation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://davethehuman.com/notes/knn/"&gt;KNN&lt;/a&gt; is a so-called &lt;em&gt;&lt;strong&gt;lazy learner&lt;/strong&gt;&lt;/em&gt; because it does not have a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;training&lt;/a&gt; step and it is immediately ready to predict, using &lt;a href="https://davethehuman.com/notes/euclidean-distance/"&gt;euclidean distance&lt;/a&gt; to find the &lt;code&gt;k&lt;/code&gt; points that are closest to the point we are predicting onto, and outputting a prediction based on these &lt;code&gt;k&lt;/code&gt; points (either using the most common &lt;code&gt;y&lt;/code&gt; class among them (&lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;classification&lt;/a&gt;) or averaging those closest points&amp;rsquo; value of &lt;code&gt;y&lt;/code&gt; (&lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;regression&lt;/a&gt;) ).&lt;/p&gt;</description></item><item><title>KNN</title><link>https://davethehuman.com/notes/knn/</link><pubDate>Sat, 10 Oct 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/knn/</guid><description>&lt;p&gt;&lt;em&gt;K nearest neighbours&lt;/em&gt; is a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;supervised learning&lt;/a&gt; algorithm that, given a data point to predict onto, uses &lt;a href="https://davethehuman.com/notes/euclidean-distance/"&gt;euclidean distance&lt;/a&gt; to calculate the distance between that point and the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;training&lt;/a&gt; data to make a prediction based on the closest $k$ points ($k$ is then an &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;hyperparameter&lt;/a&gt; defined by the user a-priori). &lt;br&gt;
In case of a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;classification&lt;/a&gt; task, it will assign a label with &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;majority voting&lt;/a&gt;; in case of a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;regression&lt;/a&gt; task it will compute the average of those closest points&amp;rsquo; value.&lt;/p&gt;</description></item><item><title>Logistic Regression from scratch</title><link>https://davethehuman.com/notes/logistic-regression-from-scratch/</link><pubDate>Thu, 08 Oct 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/logistic-regression-from-scratch/</guid><description>&lt;h2 class="relative group"&gt;Algorithm and implementation
 &lt;div id="algorithm-and-implementation" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#algorithm-and-implementation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://davethehuman.com/notes/logistic-regression/"&gt;Logistic Regression&lt;/a&gt; formula is the same as the &lt;a href="https://davethehuman.com/notes/linear-regression/"&gt;Linear Regression&lt;/a&gt;&amp;rsquo;s one passed to a &lt;a href="https://davethehuman.com/notes/sigmoid/"&gt;sigmoid&lt;/a&gt; function to obtain a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;probability score&lt;/a&gt; from &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;logits&lt;/a&gt; and can be replicated on numpy with:&lt;br&gt;
&lt;code&gt;sigmoid(X @ w + b)&lt;/code&gt; (or &lt;code&gt;sigmoid(np.dot(X,w))&lt;/code&gt;.&lt;br&gt;
The implementation of &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;gradient descent&lt;/a&gt; as an &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;optimizer&lt;/a&gt; is the same of &lt;a href="https://davethehuman.com/notes/linear-regression-from-scratch/"&gt;Linear Regression from scratch&lt;/a&gt;, what changes is the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;loss&lt;/a&gt; and the error since we deal with probabilities:&lt;/p&gt;</description></item><item><title>Linear Regression from scratch</title><link>https://davethehuman.com/notes/linear-regression-from-scratch/</link><pubDate>Tue, 06 Oct 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/linear-regression-from-scratch/</guid><description>&lt;h2 class="relative group"&gt;Algorithm and implementation
 &lt;div id="algorithm-and-implementation" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#algorithm-and-implementation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://davethehuman.com/notes/linear-regression/"&gt;Linear Regression&lt;/a&gt; formula can be replicated on numpy with &lt;code&gt;X @ w + b&lt;/code&gt; (or &lt;code&gt;np.dot(X,w)&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;To implement &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;gradient descent&lt;/a&gt; as an &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;optimizer&lt;/a&gt;, we need to calculate the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;errors = predictions - y&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The loss is &lt;a href="https://davethehuman.com/notes/rss/"&gt;RSS&lt;/a&gt; , evaluated with &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;MSE&lt;/a&gt;.&lt;br&gt;
&lt;code&gt;loss = np.mean(errors - y)**2&lt;/code&gt; In this case, we will actually be using the half-&lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;MSE&lt;/a&gt; to have similarities with &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;Logistic Regression from scratch&lt;/a&gt;.
$$L=\frac{1}{2N}\sum_i(\hat y_i-y_i)^2.$$Half-MSE has the same minimizer as MSE and its &lt;code&gt;1/2&lt;/code&gt; cancels the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;derivative&lt;/a&gt;&amp;rsquo;s &lt;code&gt;2&lt;/code&gt; giving the same gradient template as &lt;a href="https://davethehuman.com/notes/logistic-regression/"&gt;Logistic Regression&lt;/a&gt;:
$$dw=X^T errors/N, \qquad db=mean(errors).$$
Using &amp;ldquo;pure&amp;rdquo; MSE the derivative would have been:
$$dw=2X^T errors/N, \qquad db=mean(errors).$$&lt;/li&gt;
&lt;li&gt;weights &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;biases&lt;/code&gt; are initialized as &lt;code&gt;np.zeros&lt;/code&gt; and &lt;code&gt;np.mean(y)&lt;/code&gt; respectively, since the &lt;a href="https://davethehuman.com/notes/weights/"&gt;weights&lt;/a&gt; act as a sort of &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;feature importance&lt;/a&gt; and the &lt;a href="https://davethehuman.com/notes/bias/"&gt;bias&lt;/a&gt; works as an &lt;a href="https://davethehuman.com/notes/intercept/"&gt;intercept&lt;/a&gt; .
After choosing a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;learning rate&lt;/a&gt;, at further steps &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; will be updated as:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;w-=dw * learning_rate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;b-=db * learning_rate&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 class="relative group"&gt;Class structure
 &lt;div id="class-structure" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#class-structure" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;main attributes&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;learning_rate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;n_iterations&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/weights/"&gt;weights&lt;/a&gt; &lt;code&gt;w_&lt;/code&gt; and &lt;a href="https://davethehuman.com/notes/bias/"&gt;bias&lt;/a&gt; &lt;code&gt;b_&lt;/code&gt; initialized as &lt;code&gt;None&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fit&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;&lt;code&gt;predict&lt;/code&gt; method&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; numpy &lt;span style="color:#66d9ef"&gt;as&lt;/span&gt; np
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;LinearRegression&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__init__&lt;/span&gt;(self, learning_rate&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0.05&lt;/span&gt;, n_iterations&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1000&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;learning_rate &lt;span style="color:#f92672"&gt;=&lt;/span&gt; learning_rate
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;n_iterations &lt;span style="color:#f92672"&gt;=&lt;/span&gt; n_iterations
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;w_ &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;None&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;b_ &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;None&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;fit&lt;/span&gt;(self, X, y):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#66d9ef"&gt;pass&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;predict&lt;/span&gt;(self, X):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#66d9ef"&gt;pass&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;Training
 &lt;div id="training" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#training" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;fit&lt;/code&gt; method can be implemented following these steps:&lt;/p&gt;</description></item><item><title>accuracy</title><link>https://davethehuman.com/notes/accuracy/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/accuracy/</guid><description>&lt;p&gt;&lt;em&gt;Accuracy&lt;/em&gt; is the &lt;strong&gt;ratio of the correctly classified observations&lt;/strong&gt;.
In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt; settings, it checks the sum of &lt;a href="https://davethehuman.com/notes/tp/"&gt;TP&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/tn/"&gt;TN&lt;/a&gt; over all the predictions:
&lt;/p&gt;
$$
\mathrm{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}
$$&lt;p&gt;It is very important to use this metric on datasets that &lt;strong&gt;do not suffer from &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;class imbalance&lt;/a&gt;&lt;/strong&gt;; for example, a model that always predicts &amp;ldquo;False&amp;rdquo; on a dataset having 99.9% of False observations will have a very high 0.999 accuracy score but it won&amp;rsquo;t be meaningful for detecting the True observations.&lt;/p&gt;</description></item><item><title>classification metrics</title><link>https://davethehuman.com/notes/classification-metrics/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/classification-metrics/</guid><description>&lt;p&gt;When building a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;classifier&lt;/a&gt; we want to minimize the number of misclassified observations.
In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary&lt;/a&gt; cases, we talk about &lt;a href="https://davethehuman.com/notes/tp/"&gt;true positives&lt;/a&gt;, &lt;a href="https://davethehuman.com/notes/fp/"&gt;false positives&lt;/a&gt;, &lt;a href="https://davethehuman.com/notes/tn/"&gt;true negatives&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/fn/"&gt;false negatives&lt;/a&gt; that can be visualized in a &lt;strong&gt;confusion matrix&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;&lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="auto"
 alt="confusion-matrix"
 width="2400"
 height="1640"
 src="https://davethehuman.com/attachments/confusion-matrix_hu_51d2cad18105cc81.png"
 srcset="https://davethehuman.com/attachments/confusion-matrix_hu_51d2cad18105cc81.png 800w, https://davethehuman.com/attachments/confusion-matrix_hu_bd6c4f8161120a6d.png 1280w"
 sizes="(min-width: 768px) 50vw, 65vw"
 data-zoom-src="https://davethehuman.com/attachments/confusion-matrix.png"&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;The main classification metrics are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/accuracy/"&gt;accuracy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/precision/"&gt;precision&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/recall/"&gt;recall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/fpr/"&gt;false positive rate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Their usage depends on the classification task.&lt;/p&gt;</description></item><item><title>F1-score</title><link>https://davethehuman.com/notes/f1-score/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/f1-score/</guid><description>&lt;p&gt;&lt;em&gt;F1-score&lt;/em&gt; (also called &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;harmonic mean&lt;/a&gt;) is a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;metric&lt;/a&gt; that takes into account both &lt;a href="https://davethehuman.com/notes/precision/"&gt;precision&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/recall/"&gt;recall&lt;/a&gt;:
&lt;/p&gt;
$$
\mathrm{F1} = \frac{2*Precision*Recall}{Precision + Recall}
$$&lt;p&gt;It is widely used in &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;NLP&lt;/a&gt; and it balances precision and recall, handling &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;class imbalance&lt;/a&gt; and highlighting poor performance on minority classes.&lt;/p&gt;</description></item><item><title>FN</title><link>https://davethehuman.com/notes/fn/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/fn/</guid><description>&lt;p&gt;In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt;, a &lt;em&gt;False Negative (FN)&lt;/em&gt; is a misclassification of the model that assigns a &amp;ldquo;False&amp;rdquo; label to an observation whose label is actually &amp;ldquo;True&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Used in the &lt;a href="https://davethehuman.com/notes/classification-metrics/"&gt;classification metrics&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>FP</title><link>https://davethehuman.com/notes/fp/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/fp/</guid><description>&lt;p&gt;In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt;, a &lt;em&gt;False Positive (FP)&lt;/em&gt; is a misclassification of the model that assigns a &amp;ldquo;True&amp;rdquo; label to an observation whose actual label is &amp;ldquo;False&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Used in the &lt;a href="https://davethehuman.com/notes/classification-metrics/"&gt;classification metrics&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>FPR</title><link>https://davethehuman.com/notes/fpr/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/fpr/</guid><description>&lt;p&gt;&lt;em&gt;False Positive Rate (FPR)&lt;/em&gt; is the ratio of &lt;strong&gt;the negative observations that are classified as positives&lt;/strong&gt; (how many &lt;a href="https://davethehuman.com/notes/fp/"&gt;FP&lt;/a&gt; over the sum of &lt;a href="https://davethehuman.com/notes/tp/"&gt;FP&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/tn/"&gt;FN&lt;/a&gt;):
&lt;/p&gt;
$$
\mathrm{FPR} = \frac{FP}{FP + TN}
$$&lt;p&gt;It is used in &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;ROC-AUC&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>precision</title><link>https://davethehuman.com/notes/precision/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/precision/</guid><description>&lt;p&gt;&lt;em&gt;Precision&lt;/em&gt; is the ratio of &lt;strong&gt;the observation classified as positives that are actually positives&lt;/strong&gt;.
In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt; settings, it takes the number of &lt;a href="https://davethehuman.com/notes/tp/"&gt;TP&lt;/a&gt; and divides it by the sum of &lt;a href="https://davethehuman.com/notes/tp/"&gt;TP&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/fp/"&gt;FP&lt;/a&gt;:
&lt;/p&gt;
$$
\mathrm{Precision} = \frac{TP}{TP + FP}
$$&lt;p&gt;While &lt;a href="https://davethehuman.com/notes/recall/"&gt;recall&lt;/a&gt; uses in the denominator the total number of observations that are actually positives, precision uses the total number of observations that are &lt;strong&gt;classified as positives&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This metric is useful in cases of &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;class imbalance&lt;/a&gt; and when the false positive creates severe inconvenience, financial loss or user distrust; a typical task where precision is used as a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;metric&lt;/a&gt; is spam detection.&lt;/p&gt;</description></item><item><title>recall</title><link>https://davethehuman.com/notes/recall/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/recall/</guid><description>&lt;p&gt;&lt;em&gt;Recall&lt;/em&gt; is the ratio of &lt;strong&gt;the positive observations that are actually classified as positives&lt;/strong&gt;.
In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt; setting, it takes the number of &lt;a href="https://davethehuman.com/notes/tp/"&gt;TP&lt;/a&gt; and divides it by the sum of &lt;a href="https://davethehuman.com/notes/tp/"&gt;TP&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/fn/"&gt;FN&lt;/a&gt;:
&lt;/p&gt;
$$
\mathrm{Recall} = \frac{TP}{TP + FN}
$$&lt;p&gt;It is also called &lt;a href="https://davethehuman.com/notes/sensitivity/"&gt;sensitivity&lt;/a&gt; or &lt;a href="https://davethehuman.com/notes/tpr/"&gt;true positive rate&lt;/a&gt;. the correctly classified observations.&lt;/p&gt;
&lt;p&gt;While &lt;a href="https://davethehuman.com/notes/precision/"&gt;precision&lt;/a&gt; uses in the denominator the total number of observations classified as positives, recall uses the total number of observations that are &lt;strong&gt;actual positives&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>sensitivity</title><link>https://davethehuman.com/notes/sensitivity/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/sensitivity/</guid><description>&lt;p&gt;See &lt;a href="https://davethehuman.com/notes/recall/"&gt;recall&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>TN</title><link>https://davethehuman.com/notes/tn/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/tn/</guid><description>&lt;p&gt;In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt;, a &lt;em&gt;True Negative (TN)&lt;/em&gt; is a correct classification of the model that assigns a &amp;ldquo;False&amp;rdquo; label to an observation whose label is &amp;ldquo;False&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Used in the &lt;a href="https://davethehuman.com/notes/classification-metrics/"&gt;classification metrics&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>TP</title><link>https://davethehuman.com/notes/tp/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/tp/</guid><description>&lt;p&gt;In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;binary classification&lt;/a&gt;, a &lt;em&gt;True Positive (TP)&lt;/em&gt; is a correct classification of the model that assigns a &amp;ldquo;True&amp;rdquo; label to an observation whose label is &amp;ldquo;True&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Used in the &lt;a href="https://davethehuman.com/notes/classification-metrics/"&gt;classification metrics&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>TPR</title><link>https://davethehuman.com/notes/tpr/</link><pubDate>Tue, 29 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/tpr/</guid><description>&lt;p&gt;See &lt;a href="https://davethehuman.com/notes/recall/"&gt;recall&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Logistic Regression</title><link>https://davethehuman.com/notes/logistic-regression/</link><pubDate>Sat, 26 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/logistic-regression/</guid><description>&lt;h2 class="relative group"&gt;Formula
 &lt;div id="formula" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#formula" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Taking as a reference the &lt;a href="https://davethehuman.com/notes/linear-regression/"&gt;Linear Regression&lt;/a&gt;, in &lt;em&gt;Logistic Regression&lt;/em&gt; the linear output is converted into a probability between 0 and 1 using the &lt;a href="https://davethehuman.com/notes/sigmoid/"&gt;sigmoid&lt;/a&gt; function:&lt;/p&gt;
$$\sigma(z) = \frac{1}{1 + e^{-z}}$$&lt;p&gt;With \(z = \beta_0 + X\beta\) as the linear score, the model&amp;rsquo;s predicted probability is
\(\hat{p} = \sigma(z) = \sigma(\beta_0 + X\beta) = \frac{1}{1 + e^{-(\beta_0 + X\beta)}}\).&lt;/p&gt;</description></item><item><title>Linear Regression</title><link>https://davethehuman.com/notes/linear-regression/</link><pubDate>Thu, 24 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/linear-regression/</guid><description>&lt;h2 class="relative group"&gt;Formula
 &lt;div id="formula" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#formula" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;When using &lt;em&gt;Linear Regression&lt;/em&gt;, the goal is to estimate a function $f(x)$ such that each &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;feature&lt;/a&gt; has a &lt;strong&gt;linear relationship&lt;/strong&gt; to the target variable $y$.&lt;br&gt;
This is a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;supervised learning&lt;/a&gt; model written as:
&lt;/p&gt;
$$
y = \beta_0 + X\beta
$$&lt;p&gt;with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$\beta_0$ = &lt;a href="https://davethehuman.com/notes/intercept/"&gt;intercept&lt;/a&gt; (or &lt;a href="https://davethehuman.com/notes/bias/"&gt;bias&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;$X$ = matrix of &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;predictor&lt;/a&gt; variables&lt;/li&gt;
&lt;li&gt;$\beta$ = vector of parameters that determine the &lt;a href="https://davethehuman.com/notes/weights/"&gt;weights&lt;/a&gt; for each variable. For a single predictor, the sign of $\beta$ gives the direction of the relationship:
&lt;ul&gt;
&lt;li&gt;$\beta &gt; 0$ is positive&lt;/li&gt;
&lt;li&gt;$\beta &lt; 0$ is negative&lt;/li&gt;
&lt;li&gt;$\beta = 0$ means no linear effect.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure&gt;&lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="auto"
 alt="linear regression"
 width="2000"
 height="1300"
 src="https://davethehuman.com/attachments/linear_regression_hu_12905239a6b86b3e.png"
 srcset="https://davethehuman.com/attachments/linear_regression_hu_12905239a6b86b3e.png 800w, https://davethehuman.com/attachments/linear_regression_hu_1cb26931883e32fb.png 1280w"
 sizes="(min-width: 768px) 50vw, 65vw"
 data-zoom-src="https://davethehuman.com/attachments/linear_regression.png"&gt;&lt;/figure&gt;
&lt;/p&gt;</description></item></channel></rss>