<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Watermelon Book on eree's blog</title><link>https://blog.ereebay.me/en/tags/watermelon-book/</link><description>Recent content in Watermelon Book on eree's blog</description><generator>Hugo</generator><language>en</language><copyright>2020-2026 eree&amp;rsquo;s blog</copyright><lastBuildDate>Wed, 24 Jun 2020 18:15:38 +0800</lastBuildDate><atom:link href="https://blog.ereebay.me/en/tags/watermelon-book/index.xml" rel="self" type="application/rss+xml"/><item><title>Watermelon Book Reading Notes 1. Introduction</title><link>https://blog.ereebay.me/en/posts/melonbook-1/</link><pubDate>Wed, 24 Jun 2020 18:15:38 +0800</pubDate><guid>https://blog.ereebay.me/en/posts/melonbook-1/</guid><description>&lt;h1 id="introduction"&gt;Introduction&lt;/h1&gt;
&lt;h2 id="preamble"&gt;Preamble&lt;/h2&gt;
&lt;p&gt;Machine learning: suppose we use P to evaluate the performance of a computer program on a certain class of tasks T; if a program improves its performance on the tasks in T through experience E, then we say that, with respect to T and P, the program has learned from E.&lt;/p&gt;
&lt;!-- more --&gt;
&lt;h2 id="basic-terminology"&gt;Basic Terminology&lt;/h2&gt;
&lt;p&gt;Data-related:&lt;/p&gt;
&lt;p&gt;A dataset contains a series of records, and each record is an instance or a sample. That which reflects certain properties is an attribute or a feature. The value an attribute takes is called the attribute value, and the space spanned by the attributes is called the attribute space, the sample space, or the input space. Every point in this space is called a feature vector.&lt;/p&gt;</description><content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<h2 id="preamble">Preamble</h2>
<p>Machine learning: suppose we use P to evaluate the performance of a computer program on a certain class of tasks T; if a program improves its performance on the tasks in T through experience E, then we say that, with respect to T and P, the program has learned from E.</p>
<!-- more -->
<h2 id="basic-terminology">Basic Terminology</h2>
<p>Data-related:</p>
<p>A dataset contains a series of records, and each record is an instance or a sample. That which reflects certain properties is an attribute or a feature. The value an attribute takes is called the attribute value, and the space spanned by the attributes is called the attribute space, the sample space, or the input space. Every point in this space is called a feature vector.</p>
<p>Training-related:</p>
<p>The process of learning a model from data is called learning or training. The data used is called training data, each sample is a training sample, and the whole collection is called the training set. The learned model corresponds to some underlying regularity in the data, which is called a hypothesis. The regularity itself is called the ground truth. The model can also be called a learner.</p>
<p>After training, predictions need to be made. Information about the outcome of an instance is called a label, and an instance with a label is an example. The space spanned by the labels is the label space or the output space.</p>
<p>Classification: the predicted values are discrete. Regression: the predicted values are continuous. Binary classification: the outputs are the positive class and the negative class.</p>
<p>The stage of making predictions with the learned model is called testing; the samples being predicted are called testing samples, and likewise there is a testing set</p>
<p>Supervised learning: training with labeled data, such as classification and regression.</p>
<p>Unsupervised learning: training with unlabeled data, such as clustering, which divides training samples into clusters.</p>
<p>Generalization: the ability of a model to work well on new samples</p>
<p>Independent and identically distributed (iid): the samples are all drawn independently from the same distribution.</p>
<h2 id="hypothesis-space">Hypothesis Space</h2>
<p>Induction: from the specific to the general. (generalization)</p>
<p>Deduction: from the general to the specific. (specialization)</p>
<p>Inductive learning: in the broad sense, learning from samples; in the narrow sense, acquiring concepts from data, which is called concept learning.</p>
<p>Version space: the set of hypotheses consistent with the training set</p>
<h2 id="inductive-bias">Inductive Bias</h2>
<p>Inductive bias: the preference of a machine learning algorithm for a certain type of hypothesis during the learning process; it corresponds to the assumption the learning algorithm itself makes about &ldquo;what kind of model is better&rdquo;</p>
]]></content:encoded></item><item><title>Watermelon Book Reading Notes 2. Model Evaluation and Selection</title><link>https://blog.ereebay.me/en/posts/melonbook-2/</link><pubDate>Wed, 24 Jun 2020 16:06:16 +0800</pubDate><guid>https://blog.ereebay.me/en/posts/melonbook-2/</guid><description>&lt;h1 id="model-evaluation-and-selection"&gt;Model Evaluation and Selection&lt;/h1&gt;
&lt;h2 id="empirical-error-and-overfitting"&gt;Empirical Error and Overfitting&lt;/h2&gt;
&lt;p&gt;Error rate: the overall proportion of misclassified samples&lt;/p&gt;
&lt;p&gt;Accuracy: the proportion of correctly classified samples&lt;/p&gt;
&lt;p&gt;Error: the difference between the actual output and the true output; on training samples it is the empirical error or training error, and on new samples it is the generalization error&lt;/p&gt;
&lt;p&gt;Overfitting: generalization performance degrades&lt;/p&gt;
&lt;p&gt;Underfitting: performs poorly even on the training samples&lt;/p&gt;
&lt;!-- more --&gt;
&lt;h2 id="evaluation-methods"&gt;Evaluation Methods&lt;/h2&gt;
&lt;p&gt;A testing set is typically used to measure a model&amp;rsquo;s performance, with the testing error serving as an approximation of the generalization error&lt;/p&gt;</description><content:encoded><![CDATA[<h1 id="model-evaluation-and-selection">Model Evaluation and Selection</h1>
<h2 id="empirical-error-and-overfitting">Empirical Error and Overfitting</h2>
<p>Error rate: the overall proportion of misclassified samples</p>
<p>Accuracy: the proportion of correctly classified samples</p>
<p>Error: the difference between the actual output and the true output; on training samples it is the empirical error or training error, and on new samples it is the generalization error</p>
<p>Overfitting: generalization performance degrades</p>
<p>Underfitting: performs poorly even on the training samples</p>
<!-- more -->
<h2 id="evaluation-methods">Evaluation Methods</h2>
<p>A testing set is typically used to measure a model&rsquo;s performance, with the testing error serving as an approximation of the generalization error</p>
<h3 id="hold-out-method">Hold-Out Method</h3>
<p>Split the dataset D into two mutually exclusive sets, one part as the training set S and the other as the testing set T. When S is large and T is small, the evaluation may not be accurate enough. If T is made larger, then the model trained on S may differ too much from the model that would be trained on D, and the evaluation result will not be accurate enough either.</p>
<h3 id="cross-validation">Cross-Validation</h3>
<p>Split the dataset D into k mutually exclusive subsets, use k-1 of them as the training set and the remaining one as the testing set; this yields k groups of data, and the average of the testing results of these k groups is returned as the final result. The extreme case is leave-one-out, which gives more accurate results but at a greater computational cost.</p>
<h3 id="bootstrap">Bootstrap</h3>
<p>Use bootstrap sampling to draw a new dataset <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>D</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">D&#x27;</annotation></semantics></math></span> with replacement. Train on this new dataset and test on the rest. Advantage: this method is useful when the dataset is small and it is difficult to split training/testing sets effectively. Disadvantage: it changes the distribution of the initial dataset and introduces estimation bias.</p>
<h3 id="parameter-tuning-and-the-final-model">Parameter Tuning and the Final Model</h3>
<p>Algorithm parameters have a great impact on the algorithm&rsquo;s performance. Besides choosing an algorithm, its parameters also need to be adjusted, i.e., parameter tuning. After the model has been evaluated and selected using a validation set and the model and parameter configuration are determined, the model must be retrained once on the entire dataset D before testing — this is the finally submitted model. To distinguish it, the data used during model evaluation is called the validation set. The validation set is used to evaluate algorithm selection and parameter tuning, while the testing set is used to evaluate the generalization performance of the algorithm.</p>
<h2 id="performance-measures">Performance Measures</h2>
<p>Performance measure: the evaluation criterion used to measure a model&rsquo;s generalization ability</p>
<p>The most commonly used performance measure for regression tasks is MSE, the mean squared error:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mn>1</mn><mi>m</mi></mfrac><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></msubsup><msup><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo>−</mo><msub><mi>y</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">E(f ; D)=\frac{1}{m} \sum_{i=1}^{m}\left(f\left(x_{i}\right)-y_{i}\right)^{2}</annotation></semantics></math></span><p>More generally, it can be written as:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo>=</mo><msub><mo>∫</mo><mrow><mi>x</mi><mo>∼</mo><mi>D</mi></mrow></msub><mo stretchy="false">(</mo><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>−</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mi>p</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mi>d</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">E(f ; D)=\int_{x \sim D}(f(x)-y)^{2} p(x) d x</annotation></semantics></math></span><h3 id="error-rate-and-accuracy">Error Rate and Accuracy</h3>
<p>The two most commonly used performance measures: error rate and accuracy</p>
<p>Error rate: <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mn>1</mn><mi>m</mi></mfrac><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></msubsup><mi>I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo mathvariant="normal">≠</mo><msub><mi>y</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">E(f ; D)=\frac{1}{m} \sum_{i=1}^{m} I\left(f\left(x_{i}\right) \neq y_{i}\right)</annotation></semantics></math></span></p>
<p>Accuracy: <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">acc</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mn>1</mn><mi>m</mi></mfrac><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></munderover><mi mathvariant="double-struck">I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo>=</mo><msub><mi>y</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mn>1</mn><mo>−</mo><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned} \operatorname{acc}(f ; D) &amp;=\frac{1}{m} \sum_{i=1}^{m} \mathbb{I}\left(f\left(x_{i}\right)=y_{i}\right) \\ &amp;=1-E(f ; D) \end{aligned}</annotation></semantics></math></span></p>
<h3 id="precision-recall-and-f1">Precision, Recall, and F1</h3>
<p>In information retrieval, one usually cares about &ldquo;how much of the retrieved information the user is interested in&rdquo; and &ldquo;how much of what the user is interested in has been retrieved&rdquo;. This motivates the concepts of precision and recall.</p>
<p>For binary classification problems,</p>
<p>Precision = true positives / (true positives + false positives)</p>
<p>Recall = true positives / (true positives + false negatives)</p>
<p>These two metrics usually conflict with each other: when recall is high, precision is relatively low. For example, to select as many good melons as possible, simply selecting every melon guarantees that all the good ones are selected.</p>
<p>P-R curve: the precision-recall curve. If one learner&rsquo;s PR curve can completely envelop another learner&rsquo;s curve, the former learner is better. A more reasonable criterion is the size of the area under the curve, but it is not easy to estimate, so there are three evaluation approaches.</p>
<ol>
<li>Break-Even Point (BEP): the value at which precision equals recall.</li>
<li>F1 measure: F1=2<em>P</em>R/(P+R)= 2*TP/(total number of examples+TP-TN), based on the harmonic mean of P and R <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><msub><mi>F</mi><mn>1</mn></msub></mfrac><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mrow><mo fence="true">(</mo><mfrac><mn>1</mn><mi>P</mi></mfrac><mo>+</mo><mfrac><mn>1</mn><mi>R</mi></mfrac><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\frac{1}{F_{1}}=\frac{1}{2}\left(\frac{1}{P}+\frac{1}{R}\right)</annotation></semantics></math></span></li>
<li>The general form of the F1 measure (when P and R are weighted differently): <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>F</mi><mi>β</mi></msub><mo>=</mo><mfrac><mrow><mrow><mo fence="true">(</mo><mn>1</mn><mo>+</mo><msup><mi>β</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow><mo>×</mo><mi>P</mi><mo>×</mo><mi>R</mi></mrow><mrow><mrow><mo fence="true">(</mo><msup><mi>β</mi><mn>2</mn></msup><mo>×</mo><mi>P</mi><mo fence="true">)</mo></mrow><mo>+</mo><mi>R</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">F_{\beta}=\frac{\left(1+\beta^{2}\right) \times P \times R}{\left(\beta^{2} \times P\right)+R}</annotation></semantics></math></span>, based on the harmonic mean <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><msub><mi>F</mi><mi>β</mi></msub></mfrac><mo>=</mo><mfrac><mn>1</mn><mrow><mn>1</mn><mo>+</mo><msup><mi>β</mi><mn>2</mn></msup></mrow></mfrac><mrow><mo fence="true">(</mo><mfrac><mn>1</mn><mi>P</mi></mfrac><mo>+</mo><mfrac><msup><mi>β</mi><mn>2</mn></msup><mi>R</mi></mfrac><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\frac{1}{F_{\beta}}=\frac{1}{1+\beta^{2}}\left(\frac{1}{P}+\frac{\beta^{2}}{R}\right)</annotation></semantics></math></span>  <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span> represents the relative importance of the two: it degenerates to F1 when equal to 1, recall matters more when it is greater than 1, and precision matters more when it is less than 1.</li>
</ol>
<p>Sometimes P and R need to be computed over n binary confusion matrices and then averaged, giving macro-precision, macro-recall, and macro-F1. Alternatively, the corresponding elements of the confusion matrices can be averaged first to obtain averaged positive and negative counts, from which micro-precision, micro-recall, and micro-F1 are then computed.</p>
<h3 id="roc-and-auc">ROC and AUC</h3>
<p>ROC: Receiver Operating Characteristic curve.</p>
<p>A learner typically outputs a probability prediction for an input sample, which is then compared against a classification threshold. The model ranks the samples most likely to be positive at the front and the least likely at the back, then splits the samples into two parts at a certain cut point: the first part is judged positive and the second part negative.</p>
<p>Different classification tasks adopt different cut points: if precision matters more, the cut point is moved forward; if recall is valued more, it is moved backward.</p>
<p>Sort the samples according to the learner&rsquo;s prediction results, and compute two values in that order.</p>
<p>Vertical axis: True Positive Rate (TPR): <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mi>P</mi><mi>R</mi><mo>=</mo><mfrac><mrow><mi>T</mi><mi>P</mi></mrow><mrow><mi>T</mi><mi>P</mi><mo>+</mo><mi>F</mi><mi>N</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">T P R=\frac{T P}{T P+F N}</annotation></semantics></math></span></p>
<p>Horizontal axis: False Positive Rate (FPR): <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mi>P</mi><mi>R</mi><mo>=</mo><mfrac><mrow><mi>F</mi><mi>P</mi></mrow><mrow><mi>T</mi><mi>N</mi><mo>+</mo><mi>F</mi><mi>P</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">FPR=\frac {FP} {TN+FP}</annotation></semantics></math></span>
<img alt="Untitled" loading="lazy" src="http://cdn.ereebay.me/hexo/Untitled.png"></p>
<p>When comparing learners, if one curve can envelop the other, the former is better; if they cross, neither clearly dominates. A more reasonable judgment is to compare the area under the ROC curve, i.e., the AUC.</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>U</mi><mi>C</mi><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mrow><mi>m</mi><mo>−</mo><mn>1</mn></mrow></msubsup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mrow><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><mo>−</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mrow><mo fence="true">(</mo><msub><mi>y</mi><mi>i</mi></msub><mo>+</mo><msub><mi>y</mi><mrow><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">A U C=\frac{1}{2} \sum_{i=1}^{m-1}\left(x_{i+1}-x_{i}\right)\left(y_{i}+y_{i+1}\right)</annotation></semantics></math></span><p>Loss: <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal"><msub><mi mathvariant="normal">l</mi><mrow><mi mathvariant="normal">r</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">k</mi></mrow></msub></mi><mo>⁡</mo><mo>=</mo><mfrac><mn>1</mn><mrow><msup><mi>m</mi><mo lspace="0em" rspace="0em">+</mo></msup><msup><mi>m</mi><mo lspace="0em" rspace="0em">−</mo></msup></mrow></mfrac><msub><mo>∑</mo><mrow><msup><mi>x</mi><mo lspace="0em" rspace="0em">+</mo></msup><mo>∈</mo><msup><mi>D</mi><mo lspace="0em" rspace="0em">+</mo></msup></mrow></msub><msub><mo>∑</mo><mrow><mi>x</mi><mo>∈</mo><msup><mi>D</mi><mo lspace="0em" rspace="0em">−</mo></msup></mrow></msub><mrow><mo fence="true">(</mo><mi mathvariant="double-struck">I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msup><mi>x</mi><mo lspace="0em" rspace="0em">+</mo></msup><mo fence="true">)</mo></mrow><mo>&lt;</mo><mi>f</mi><mrow><mo fence="true">(</mo><msup><mi>x</mi><mo lspace="0em" rspace="0em">−</mo></msup><mo fence="true">)</mo></mrow><mo fence="true">)</mo></mrow><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi mathvariant="double-struck">I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msup><mi>x</mi><mo lspace="0em" rspace="0em">+</mo></msup><mo fence="true">)</mo></mrow><mo>=</mo><mi>f</mi><mrow><mo fence="true">(</mo><msup><mi>x</mi><mo lspace="0em" rspace="0em">−</mo></msup><mo fence="true">)</mo></mrow><mo fence="true">)</mo></mrow><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\operatorname{l_{rank}}=\frac{1}{m^{+} m^{-}} \sum_{x^{+} \in D^{+}} \sum_{x \in D^{-}}\left(\mathbb{I}\left(f\left(x^{+}\right)&lt;f\left(x^{-}\right)\right)+\frac{1}{2} \mathbb{I}\left(f\left(x^{+}\right)=f\left(x^{-}\right)\right)\right)</annotation></semantics></math></span></p>
<p>AUC= 1-lrank</p>
<p><a href="https://datawhalechina.github.io/pumpkin-book/#/chapter2/chapter2">https://datawhalechina.github.io/pumpkin-book/#/chapter2/chapter2</a> For more details, see the Pumpkin Book</p>
<h3 id="cost-sensitive-error-rate-and-cost-curve">Cost-Sensitive Error Rate and Cost Curve</h3>
<p>To weigh the different losses caused by different types of errors, errors can be assigned &ldquo;unequal costs&rdquo;</p>
<p>Taking binary classification as an example, set up a cost matrix</p>
<p>Binary classification cost matrix</p>
<table>
	<thead>
			<tr>
					<th>True class</th>
					<th>Predicted class 0</th>
					<th>Predicted class 1</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>0</td>
					<td>0</td>
					<td>cost01</td>
			</tr>
			<tr>
					<td>1</td>
					<td>cost10</td>
					<td>0</td>
			</tr>
	</tbody>
</table>
<p>If misclassifying 0 as 1 is considered the greater loss, then cost01 is greater than cost10; the greater the difference in loss, the greater the difference between the values.</p>
<p>The performance measures introduced above all implicitly assume equal costs; under unequal costs, the goal becomes minimizing the total cost overall</p>
<p>The cost-sensitive error rate is:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo separator="true">;</mo><mi>cos</mi><mo>⁡</mo><mi>t</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mn>1</mn><mi>m</mi></mfrac><mrow><mo fence="true">(</mo><msub><mo>∑</mo><mrow><msub><mi>x</mi><mi>i</mi></msub><mo>∈</mo><msup><mi>D</mi><mo lspace="0em" rspace="0em">+</mo></msup></mrow></msub><mi mathvariant="double-struck">I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo mathvariant="normal">≠</mo><msub><mi>y</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>01</mn></msub><mo separator="true">,</mo><mspace width="1em"/><mo>+</mo><msub><mo>∑</mo><mrow><msub><mi>X</mi><mi>i</mi></msub><mo>∈</mo><msup><mi>D</mi><mo lspace="0em" rspace="0em">−</mo></msup></mrow></msub><mi mathvariant="double-struck">I</mi><mrow><mo fence="true">(</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo mathvariant="normal">≠</mo><msub><mi>y</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>10</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">
E(f ; D ; \cos t)=\frac{1}{m}\left(\sum_{x_{i} \in D^{+}} \mathbb{I}\left(f\left(x_{i}\right) \neq y_{i}\right) \times cost_{01}, \quad+\sum_{X_{i} \in D^{-}} \mathbb{I}\left(f\left(x_{i}\right) \neq y_{i}\right) \times cost_{1 0}\right)
</annotation></semantics></math></span><p>Under unequal costs, the ROC curve cannot reflect the learner&rsquo;s expected total cost, but the cost curve can serve this purpose.</p>
<p>The horizontal axis is the positive-class probability cost over [0,1]:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo stretchy="false">(</mo><mo>+</mo><mo stretchy="false">)</mo><mi>c</mi><mi>o</mi><mi>s</mi><mi>t</mi><mo>=</mo><mfrac><mrow><mi>p</mi><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>01</mn></msub></mrow><mrow><mi>p</mi><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>01</mn></msub><mo>+</mo><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>p</mi><mo stretchy="false">)</mo><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>10</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">
P(+) cost=\frac{p \times cost_{01}}{p \times cost_{01}+(1-p) \times cost_{10}}
</annotation></semantics></math></span><p>where p is the probability that an example is positive</p>
<p>The vertical axis is the normalized cost over [0,1]:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mtext>norm </mtext></msub><mo>=</mo><mfrac><mrow><mi>F</mi><mi>N</mi><mi>R</mi><mo>×</mo><mi>p</mi><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>01</mn></msub><mo>+</mo><mi>F</mi><mi>P</mi><mi>R</mi><mo>×</mo><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>p</mi><mo stretchy="false">)</mo><mo>×</mo><mi>cos</mi><mo>⁡</mo><msub><mi>t</mi><mn>10</mn></msub></mrow><mrow><mi>p</mi><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>01</mn></msub><mo>+</mo><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>p</mi><mo stretchy="false">)</mo><mo>×</mo><mi>c</mi><mi>o</mi><mi>s</mi><msub><mi>t</mi><mn>10</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">
cost_{\text {norm }}=\frac{ F N R \times p \times cost_{01}+FP R \times(1-p) \times \cos t_{10}}{p \times cost_{01} +(1-p) \times cost_{10}}
</annotation></semantics></math></span><p>FNR is the false negative rate, and FPR is the false positive rate. FNR=1-TPR</p>
<h2 id="comparative-tests">Comparative Tests</h2>
<p>Performance comparison in machine learning usually relies on statistical hypothesis tests, for the following reasons:</p>
<ol>
<li>We want to compare generalization performance, but what experiments evaluate is performance on the testing set, and the two comparison results do not necessarily agree</li>
<li>Performance on the testing set depends heavily on the choice of testing set</li>
<li>The algorithm itself involves a certain degree of randomness</li>
</ol>
<h3 id="hypothesis-testing">Hypothesis Testing</h3>
<p>The error rate <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">{\epsilon}</annotation></semantics></math></span> serves as the performance measure.
For a learner with error rate <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">{\epsilon}</annotation></semantics></math></span>, suppose we obtain a testing error of <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\epsilon}</annotation></semantics></math></span> on the testing set; this means that <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover><mo>×</mo><mi>m</mi></mrow><annotation encoding="application/x-tex">\hat{\epsilon} \times m</annotation></semantics></math></span> of the <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi></mrow><annotation encoding="application/x-tex">m</annotation></semantics></math></span> samples are misclassified. It is easy to derive that the probability of obtaining testing error <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\epsilon}</annotation></semantics></math></span> on a test set of <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi></mrow><annotation encoding="application/x-tex">m</annotation></semantics></math></span> samples, for a learner with generalization error rate <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">{\epsilon}</annotation></semantics></math></span>, is:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo stretchy="false">(</mo><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover><mo separator="true">;</mo><mi>ϵ</mi><mo stretchy="false">)</mo><mo>=</mo><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>m</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover><mo>×</mo><mi>m</mi></mrow></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><msup><mi>ϵ</mi><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover><mo>×</mo><mi>m</mi></mrow></msup><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>ϵ</mi><msup><mo stretchy="false">)</mo><mrow><mi>m</mi><mo>−</mo><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover><mo>×</mo><mi>m</mi></mrow></msup></mrow><annotation encoding="application/x-tex">
P(\hat{\epsilon} ; \epsilon)=\left(\begin{array}{c}m \\ \hat{\epsilon} \times m\end{array}\right) \epsilon^{\hat{\epsilon} \times m}(1-\epsilon)^{m-\hat{\epsilon} \times m}
</annotation></semantics></math></span><p>A binomial distribution is used for the hypothesis test. The hypothesis takes the form <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi><mo>≤</mo><msub><mi>ϵ</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\epsilon \leq \epsilon_{0}</annotation></semantics></math></span>, and the maximum error rate we can observe with probability <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><annotation encoding="application/x-tex">1-\alpha</annotation></semantics></math></span> is:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>ˉ</mo></mover><mo>=</mo><mi>max</mi><mo>⁡</mo><mi>ϵ</mi><mspace width="1em"/><mtext> s.t. </mtext><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><msub><mi>ϵ</mi><mn>0</mn></msub><mo>×</mo><mi>m</mi><mo>+</mo><mn>1</mn></mrow><mi>m</mi></msubsup><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>m</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>i</mi></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><msup><mi>ϵ</mi><mi>i</mi></msup><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>ϵ</mi><msup><mo stretchy="false">)</mo><mrow><mi>m</mi><mo>−</mo><mi>i</mi></mrow></msup><mo>&lt;</mo><mi>α</mi></mrow><annotation encoding="application/x-tex">
\bar{\epsilon}=\max \epsilon \quad \text { s.t. } \sum_{i=\epsilon_{0} \times m+1}^{m}\left(\begin{array}{c}m \\ i\end{array}\right) \epsilon^{i}(1-\epsilon)^{m-i}&lt;\alpha
</annotation></semantics></math></span><p>If the testing error <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\epsilon}</annotation></semantics></math></span> is smaller than the critical value <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ϵ</mi><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\bar{\epsilon}</annotation></semantics></math></span>, we accept the hypothesis at the <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><annotation encoding="application/x-tex">1-\alpha</annotation></semantics></math></span> confidence level; otherwise, at the significance level <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span>, we conclude that the generalization error rate is greater than <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\epsilon</annotation></semantics></math></span>.</p>
<p>If the hold-out method or cross-validation is applied multiple times, k testing error rates are obtained. The mean and variance can then be computed, and a t-test can be used for the hypothesis test. The hypothesis in this case is that the mean equals the error rate. The variable:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mi>t</mi></msub><mo>=</mo><mfrac><mrow><msqrt><mi>k</mi></msqrt><mrow><mo fence="true">(</mo><mi>μ</mi><mo>−</mo><msub><mi>ϵ</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><mi>ϵ</mi></mfrac></mrow><annotation encoding="application/x-tex">
\tau_{t}=\frac{\sqrt{k}\left(\mu-\epsilon_{0}\right)}{\epsilon}
</annotation></semantics></math></span><p>follows a t-distribution with k-1 degrees of freedom.</p>
<p>More test methods are described on p.41 of the Watermelon Book</p>
<h2 id="bias-and-variance">Bias and Variance</h2>
<p>Besides estimating generalization performance, we also want to understand why the model performs the way it does, which calls for bias-variance decomposition. Taking a regression task as an example, y_D is the label of x on the dataset, y is the true label of x, and f(x,D) is the predicted output.</p>
<p>The expected prediction is then: <span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>f</mi><mo>ˉ</mo></mover><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><msub><mi mathvariant="double-struck">E</mi><mi>D</mi></msub><mo stretchy="false">[</mo><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\bar{f}(x)=\mathbb{E}_{D}[f(x ; D)]</annotation></semantics></math></span></p>
<p>Training sets with different numbers of samples give rise to variance. Then perform the decomposition:</p>
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>E</mi><mo stretchy="false">(</mo><mi>f</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><msub><mi mathvariant="double-struck">E</mi><mo lspace="0em" rspace="0em">−</mo></msub><mi>D</mi><mrow><mo fence="true">[</mo><msup><mrow><mo fence="true">(</mo><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo>−</mo><msub><mi>y</mi><mi>D</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo fence="true">]</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><msub><mi mathvariant="double-struck">E</mi><mo lspace="0em" rspace="0em">−</mo></msub><mi>D</mi><mrow><mo fence="true">[</mo><mo stretchy="false">(</mo><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">;</mo><mi>D</mi><mo stretchy="false">)</mo><mo>−</mo><mover accent="true"><mi>f</mi><mo>ˉ</mo></mover><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo fence="true">]</mo></mrow><mo>+</mo><mo stretchy="false">(</mo><mover accent="true"><mi>f</mi><mo>ˉ</mo></mover><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>−</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>+</mo><msub><mi mathvariant="double-struck">E</mi><mo lspace="0em" rspace="0em">−</mo></msub><mi>D</mi><mrow><mo fence="true">[</mo><msup><mrow><mo fence="true">(</mo><msub><mi>y</mi><mi>D</mi></msub><mo>−</mo><mi>y</mi><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo fence="true">]</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><msup><mrow><mi mathvariant="normal">bias</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>+</mo><mi mathvariant="normal">var</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>+</mo><msup><mi>ε</mi><mn>2</mn></msup></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">
\begin{aligned} E(f ; D) &amp;=\mathbb{E}_{-} D\left[\left(f(x ; D)-y_{D}\right)^{2}\right] \\ &amp;=\mathbb{E}_{-} D\left[(f(x ; D)-\bar{f}(x))^{2}\right]+(\bar{f}(x)-y)^{2}+\mathbb{E}_{-} D\left[\left(y_{D}-y\right)^{2}\right] \\ &amp;=\operatorname{bias}^{2}(x)+\operatorname{var}(x)+\varepsilon^{2} \end{aligned}
</annotation></semantics></math></span><p>The generalization error can be decomposed into the sum of bias, variance, and noise</p>
<ul>
<li>Bias measures the deviation of the algorithm&rsquo;s expected prediction from the true result, characterizing the fitting capability of the learning algorithm itself</li>
<li>Variance measures the change in learning performance caused by changes in training sets of the same size, characterizing the impact of data perturbation</li>
<li>Noise expresses the lower bound of the expected generalization error that any learning algorithm can achieve on the current task, characterizing the difficulty of the learning problem itself.</li>
</ul>
]]></content:encoded></item></channel></rss>