{"id":6792,"date":"2026-08-16T23:18:06","date_gmt":"2026-08-17T04:18:06","guid":{"rendered":"https:\/\/ykim.synology.me\/wordpress\/?p=6792"},"modified":"2026-11-26T22:37:46","modified_gmt":"2026-11-27T04:37:46","slug":"referenced-r%c2%b2-choosing-the-baseline-in-the-r%c2%b2-denominator","status":"publish","type":"post","link":"https:\/\/ykim.synology.me\/wordpress\/referenced-r%c2%b2-choosing-the-baseline-in-the-r%c2%b2-denominator-6792\/","title":{"rendered":"Referenced R\u00b2 \u2014 Choosing the Baseline in the R\u00b2 Denominator"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/yBarn1\/Images\/main\/pools\/georgetown-resort-pool-ledge-loungers.jpg\" alt=\"\" style=\"width:auto;height:500px\"\/><\/figure>\n\n\n<style>.kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);background:var(--global-palette9, #ffffff);}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-title-list li{margin-top:0px;margin-right:8px;margin-bottom:0px;margin-left:0px;}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-title-list li:last-child{margin-right:0px;}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-title-list li .kt-tab-title, .wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title{line-height:1.4em;font-weight:regular;font-style:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;padding-top:8px;padding-right:20px;padding-bottom:8px;padding-left:20px;border-color:var(--global-palette7, #eeeeee);color:var(--global-palette4, #2D3748);background:var(--global-palette7, #eeeeee);}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title{margin-top:0px;margin-right:8px;margin-bottom:0px;margin-left:0px;}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-title-list li .kt-tab-title:hover, .wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title:hover{border-color:var(--global-palette7, #eeeeee);color:var(--global-palette3, #1A202C);background:var(--global-palette8, #F7FAFC);}.wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-title-list li.kt-tab-title-active .kt-tab-title, .wp-block-kadence-tabs .kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .kt-tabs-accordion-title.kt-tab-title-active .kt-tab-title{border-color:var(--global-palette7, #eeeeee);color:#ffffff;background:#0a6689;}@media all and (max-width: 1024px){.kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;}}@media all and (max-width: 767px){.kt-tabs-id6792_e8395a-05 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;}}<\/style>\n<div class=\"wp-block-kadence-tabs alignnone\"><div class=\"kt-tabs-wrap kt-tabs-id6792_e8395a-05 kt-tabs-has-2-tabs kt-active-tab-2 kt-tabs-layout-tabs kt-tabs-tablet-layout-inherit kt-tabs-mobile-layout-inherit kt-tab-alignment-left \"><ul class=\"kt-tabs-title-list\"><li id=\"tab-english\" class=\"kt-title-item kt-title-item-1 kt-tabs-svg-show-always kt-tabs-icon-side-right kt-tab-title-inactive\"><a href=\"#tab-english\" data-tab=\"1\" class=\"kt-tab-title kt-tab-title-1 \"><span class=\"kt-title-text\">English<\/span><\/a><\/li><li id=\"tab-korean\" class=\"kt-title-item kt-title-item-2 kt-tabs-svg-show-always kt-tabs-icon-side-right kt-tab-title-active\"><a href=\"#tab-korean\" data-tab=\"2\" class=\"kt-tab-title kt-tab-title-2 \"><span class=\"kt-title-text\">Korean<\/span><\/a><\/li><\/ul><div class=\"kt-tabs-content-wrap\">\n<div class=\"wp-block-kadence-tab kt-tab-inner-content kt-inner-tab-1 kt-inner-tab6792_8f493c-1e\"><div class=\"kt-tab-inner-content-inner\"><p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"Metrics\/R2\/R2-Denominator\/r2-denominator.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">Referenced R\u00b2 \u2014 Choosing the Baseline in the R\u00b2 Denominator<\/h1><a id=\"user-content-referenced-r--choosing-the-baseline-in-the-r-denominator\" class=\"anchor\" aria-label=\"Permalink: Referenced R\u00b2 \u2014 Choosing the Baseline in the R\u00b2 Denominator\" href=\"#referenced-r--choosing-the-baseline-in-the-r-denominator\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 15 | Created: 2026-08-15 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-question\">1. Question<\/a><\/li>\n<li><a href=\"#2-structure\">2. Structure<\/a><\/li>\n<li><a href=\"#3-variants\">3. Variants<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#31-fixed-reference-point\">3.1. Fixed Reference Point<\/a><\/li>\n<li><a href=\"#32-fixed-reference-dispersion\">3.2. Fixed Reference Dispersion<\/a><\/li>\n<li><a href=\"#33-baseline-model\">3.3. Baseline Model<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#4-meaning-and-reporting\">4. Meaning and Reporting<\/a><\/li>\n<li><a href=\"#5-cautions\">5. Cautions<\/a><\/li>\n<li><a href=\"#6-summary\">6. Summary<\/a><\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-reference-implementation\">Appendix B. Reference Implementation<\/a><\/li>\n<\/ul>\n<blockquote>\n<p dir=\"auto\">This document asks whether the denominator of the standard R\u00b2 can be replaced\nby a reference stated from outside rather than computed from the data, and\nwhat the number comes to mean once it is.<\/p>\n<\/blockquote>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Question<\/h2><a id=\"user-content-1-question\" class=\"anchor\" aria-label=\"Permalink: 1. Question\" href=\"#1-question\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The standard R\u00b2 is defined as follows.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$R^2 = 1 - \\frac{SS_{res}}{SS_{tot}} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - \\bar{y})^2} \\hspace{19em} (1)$$<\/math-renderer><\/p>\n<p dir=\"auto\">The denominator <code>SS_tot<\/code> is the total sum of squares taken about the mean\n<code>y_bar<\/code> of the data itself, and it is the quantity usually called the total\nspread of the data. Whether that denominator can be replaced by a value stated\nfrom outside instead of computed from the data is the question of this document.<\/p>\n<p dir=\"auto\">The answer is that it can. Not only is it natural in principle, several\nestablished forms already exist. But the meaning of the metric changes the\nmoment the denominator does, so what it was replaced by must always be reported\nwith it.<\/p>\n<p dir=\"auto\">A metric built by stating the denominator this way is called a <strong>Referenced R\u00b2<\/strong>\nin this document and written <code>Ref_R2<\/code>. Section 3 divides the individual variants\nby what goes into the denominator: <code>R2_oos<\/code> (out-of-sample), <code>R2_frd<\/code> (fixed\nreference dispersion), and <code>R2_base<\/code> (baseline model).<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. Structure<\/h2><a id=\"user-content-2-structure\" class=\"anchor\" aria-label=\"Permalink: 2. Structure\" href=\"#2-structure\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Why the denominator may be changed becomes clear on rereading R\u00b2. <code>SS_tot<\/code> is\nexactly the sum of squared errors of a model that always predicts <code>y_bar<\/code>. That\nis, R\u00b2 had the form below from the start.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"                error left by the model\nR2 = 1 -  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n            error left by a chosen baseline\"><pre lang=\"text\" class=\"notranslate\"><code>                error left by the model\nR2 = 1 -  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n            error left by a chosen baseline\n<\/code><\/pre><\/div>\n<p dir=\"auto\">The standard R\u00b2 is the special case that fixes the baseline to a model which\nonly ever returns the mean, and this structure is widely used under the name\nskill score. <strong>Stating the denominator is changing the baseline, no more and no\nless.<\/strong> This fact governs the rest of the document.<\/p>\n<p dir=\"auto\"><code>Ref_R2<\/code> is therefore not a new calculation but an R\u00b2 whose baseline was chosen\nexplicitly, and the standard R\u00b2 is the case that left that baseline implicitly\nat the mean of the data.<\/p>\n<p dir=\"auto\">Numerator and denominator are both in units of y squared, so the ratio is\ndimensionless, and <code>Ref_R2<\/code> reads as what percentage of the error the baseline\nhad to accept was removed by the model. That reading holds whatever the baseline\nis.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. Variants<\/h2><a id=\"user-content-3-variants\" class=\"anchor\" aria-label=\"Permalink: 3. Variants\" href=\"#3-variants\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><strong>Table 1. Ways to choose the baseline<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Symbol<\/th>\n<th>Denominator<\/th>\n<th>Baseline it encodes<\/th>\n<th>Typical use<\/th>\n<th>Reference<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>R\u00b2<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_bar)\u00b2<\/code><\/td>\n<td>The mean of this dataset<\/td>\n<td>Goodness of fit within one dataset<\/td>\n<td>[<a href=\"#ref-1\">1<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_oos<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_train_bar)\u00b2<\/code><\/td>\n<td>The mean known at training time<\/td>\n<td>Test set evaluation<\/td>\n<td>[<a href=\"#ref-2\">2<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_frd<\/code><\/td>\n<td><code>N \u00b7 sigma_ref\u00b2<\/code><\/td>\n<td>The spread the spec allows<\/td>\n<td>Comparison across lots, batches, periods<\/td>\n<td>[<a href=\"#ref-3\">3<\/a>], [<a href=\"#ref-4\">4<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_base<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_base_i)\u00b2<\/code><\/td>\n<td>A reference model answering per sample<\/td>\n<td>Time series, comparison against a model in production<\/td>\n<td>[<a href=\"#ref-5\">5<\/a>]<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The Reference column points at where each form is actually in use, and the\nbibliography is in <a href=\"#references\">References<\/a>. None of the four is a calculation\nthis document invented; each is already standard in its own field. What this\ndocument added is notation rather than arithmetic, and section 4 returns to\nthat.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.1. Fixed Reference Point<\/h3><a id=\"user-content-31-fixed-reference-point\" class=\"anchor\" aria-label=\"Permalink: 3.1. Fixed Reference Point\" href=\"#31-fixed-reference-point\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">This is the most common case. When a test set is evaluated, the reference in the\ndenominator is anchored to the mean of the training data, <code>y_train_bar<\/code>, rather\nthan to the mean of the test data.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$R^2_{oos} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - \\bar{y}_{train})^2} \\hspace{19em} (2)$$<\/math-renderer><\/p>\n<p dir=\"auto\">Two reasons make this the right form. First, the mean of the test data is not\nknowable at evaluation time, so putting it in the baseline amounts to borrowing\ninformation from the future. Second, the denominator moves with how the test set\nwas cut, which leaves the yardstick itself unsteady. Anchoring to the training\nmean turns the metric into the question of how much the model improved on one\nthat keeps returning the mean it knew during training, and the yardstick then\nholds however the data was split.<\/p>\n<p dir=\"auto\">This form is known outside as the out-of-sample R\u00b2, so external reports use that\nname.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.2. Fixed Reference Dispersion<\/h3><a id=\"user-content-32-fixed-reference-dispersion\" class=\"anchor\" aria-label=\"Permalink: 3.2. Fixed Reference Dispersion\" href=\"#32-fixed-reference-dispersion\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The denominator is replaced by a known reference variance instead of being\ncomputed from the data.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$R^2_{frd} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{N \\cdot \\sigma_{ref}^2} \\hspace{19em} (3)$$<\/math-renderer><\/p>\n<p dir=\"auto\">For <code>sigma_ref<\/code> one uses a domain reference such as the spread a process spec\nallows, the variance of accumulated historical data, or the reference variance\nof a metrology system. For a thickness prediction, putting the control spec\nspread of the layer in question into the denominator turns the metric into a\nmeasure of the model against a fixed yardstick.<\/p>\n<p dir=\"auto\">Because the denominator is a constant, the expression reduces one step further.\nThe square root of the numerator <code>SS_res<\/code> divided by the sample count <code>N<\/code> is the\nroot mean squared error, RMSE.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$\\mathrm{RMSE} = \\sqrt{\\frac{SS_{res}}{N}} \\hspace{19em} (4)$$<\/math-renderer><\/p>\n<p dir=\"auto\">RMSE returns the error to the same unit as y, so it can be divided by\n<code>sigma_ref<\/code> directly. Substituting <code>N \u00b7 RMSE\u00b2<\/code> for <code>SS_res<\/code> cancels <code>N<\/code> and leaves only the\nfollowing.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$R^2_{frd} = 1 - \\left(\\frac{\\mathrm{RMSE}}{\\sigma_{ref}}\\right)^2 \\hspace{19em} (5)$$<\/math-renderer><\/p>\n<p dir=\"auto\">This is the physical meaning of the variant. <code>R2_frd<\/code> <strong>measures how many times\nthe spec spread the model error is<\/strong> and subtracts that from 1. Half the spec\ngives 0.75, error equal to the spec gives 0, and error beyond the spec gives a\nnegative value. Put in the language of baselines, the reference is an imaginary\nmodel whose error is exactly what the spec allows, and the question is whether\nthe model beat it.<\/p>\n<p dir=\"auto\">Metrology has a practice of reporting the ratio of error to spec as it is rather\nthan dressing it up as an R\u00b2. When the reader is a process or metrology\nengineer, handing over <code>RMSE \/ sigma_ref<\/code> unchanged communicates better; when\nthe number has to sit in one table beside other metrics, converting it to\n<code>R2_frd<\/code> puts it on the 0-to-1 scale. The two convert to each other by the\nexpression above, so they carry the same information.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.3. Baseline Model<\/h3><a id=\"user-content-33-baseline-model\" class=\"anchor\" aria-label=\"Permalink: 3.3. Baseline Model\" href=\"#33-baseline-model\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The baseline in section 3.1 answers with one number, <code>y_train_bar<\/code>, whatever\nsample it meets, and the baseline in section 3.2 makes an error of <code>sigma_ref<\/code>\nwhatever sample it meets. Both are constant baselines whose reference does not\nvary with the sample.<\/p>\n<p dir=\"auto\">A case where the reference itself has to vary per sample cannot be written in\nthat form. There the baseline holds its own value <code>y_base_i<\/code> for each i.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"17c3da301857ecbf191976f5b3024928\">$$R^2_{base} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - y_{base,i})^2} \\hspace{19em} (6)$$<\/math-renderer><\/p>\n<p dir=\"auto\">The persistence baseline of a time series is the representative case. It uses\nthe value at the previous step as the prediction for the next, so <code>y_base_i<\/code>\ndiffers for each i and no constant can produce the same denominator. The same\nholds when a seasonal mean serves as the baseline, and when a model currently in\nproduction serves as the baseline to measure the value of replacing it.<\/p>\n<p dir=\"auto\">Setting <code>y_base_i<\/code> to the constant <code>y_train_bar<\/code> reduces this to section 3.1, so\nthat section is a special case of this one. They are kept apart because the two\nanswer different questions. Section 3.1 asks whether the model beats the mean;\nsection 3.3 asks whether it beats what is already in use. The first question\ndecides whether a model is worth anything, the second whether it is worth a\nreplacement.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">4. Meaning and Reporting<\/h2><a id=\"user-content-4-meaning-and-reporting\" class=\"anchor\" aria-label=\"Permalink: 4. Meaning and Reporting\" href=\"#4-meaning-and-reporting\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ud83d\udca1 The real reason for fixing the denominator is not convenience but that <strong>the\nstandard R\u00b2 cannot be used to compare across datasets<\/strong>. The denominator is\nrecomputed for every dataset, so the yardstick changes with the dataset.<\/p>\n<p dir=\"auto\">The problem is plain in a case where one model applied to three lots gives the\nsame RMSE of 0.5 nm in all three.<\/p>\n<p dir=\"auto\"><strong>Table 2. The same model on three lots, RMSE fixed at 0.5 nm<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Lot<\/th>\n<th>Lot dispersion (nm)<\/th>\n<th>Standard R\u00b2<\/th>\n<th><code>R2_frd<\/code> against a spec of 1.0 nm<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>2.0<\/td>\n<td>0.9375<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>1.2<\/td>\n<td>0.8264<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>0.6<\/td>\n<td>0.3056<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The prediction error of the model is identical across the three lots, yet the\nstandard R\u00b2 spreads from 0.94 down to 0.31. What changed is the denominator, not\nthe model. A lot with a large spread is one the baseline was already failing on,\nso the same performance looks good; a lot with a small spread is one the\nbaseline was already handling, so the same performance looks bad. The standard\nR\u00b2 is only reporting this honestly, and ranking lots by this value ranks the\nspread of the lots rather than the model.<\/p>\n<p dir=\"auto\">Fixing the denominator at 1.0 nm gives 0.75 for all three, and the metric then\nreflects the performance of the model alone. Put differently, the two metrics\nanswer different questions.<\/p>\n<ul dir=\"auto\">\n<li>Standard R\u00b2 \u2014 how much better than the mean the model is within this dataset. The yardstick differs per dataset.<\/li>\n<li><code>R2_frd<\/code> \u2014 how much better than a stated yardstick the model is. It can be compared across datasets.<\/li>\n<\/ul>\n<p dir=\"auto\">Which one is right depends on the question. Asking how much of this lot was\nexplained calls for the standard R\u00b2; asking whether the model can be deployed\nacross the line calls for <code>R2_frd<\/code>.<\/p>\n<p dir=\"auto\">A single value handed over on its own is therefore not enough. The answers to\nboth questions land in the same place in the same shape, so the recipient cannot\ntell which one was seen. Reporting follows the rules below.<\/p>\n<ul dir=\"auto\">\n<li>Use the symbol that matches the variant rather than <code>R\u00b2<\/code> itself. The same symbol invites the reader to take it for the standard R\u00b2.<\/li>\n<li>The symbol alone does not carry enough, so record the reference of the denominator together with its value and its source. Write <code>R2_frd = 0.75 (reference: spec tolerance sigma = 1.0 nm)<\/code> rather than the number alone.<\/li>\n<li>Report the standard R\u00b2 alongside. The gap between the two is what tells the reader which way the spread of that dataset leans against the spec.<\/li>\n<li>Leave the grounds for the choice of <code>sigma_ref<\/code>. A denominator chosen without grounds makes the whole metric arbitrary.<\/li>\n<\/ul>\n<p dir=\"auto\"><code>Ref_R2<\/code>, <code>R2_frd<\/code>, and <code>R2_base<\/code> are names set by this document and do not\ncarry outside it. When sending them out, attach a one-line definition after the\nsymbol, or use the established name where one exists, as in section 3.1.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">5. Cautions<\/h2><a id=\"user-content-5-cautions\" class=\"anchor\" aria-label=\"Permalink: 5. Cautions\" href=\"#5-cautions\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>Negative values occur.<\/strong> When the model is worse than the baseline, <code>SS_res<\/code> exceeds the denominator and the value drops below 0. Against a spec of 1.0 nm, an RMSE of 1.3 nm gives \u22120.69. This is not an error but the normal signal that the baseline is the better thing to use, and it is common in out-of-sample evaluation.<\/li>\n<li><strong>A small denominator makes the value explode.<\/strong> Applying this metric to an item whose spec spread is very small produces a large negative value from a small error. Such items are better managed by the absolute size of the error than by anything in the R\u00b2 family.<\/li>\n<li><strong>The upper bound is still 1.<\/strong> Changing the denominator cannot push <code>SS_res<\/code> below 0, so the value never exceeds 1. A value near 1 does not mean the model is perfect; it means the stated baseline was overwhelmed.<\/li>\n<li><strong>The denominator is not chosen after the fact.<\/strong> Picking a flattering <code>sigma_ref<\/code> after seeing the results turns the metric into rhetoric. Fix the reference before the evaluation and record it.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">6. Summary<\/h2><a id=\"user-content-6-summary\" class=\"anchor\" aria-label=\"Permalink: 6. Summary\" href=\"#6-summary\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The denominator of R\u00b2 is the error of a baseline, and the standard R\u00b2 is the\nspecial case that fixes that baseline to the mean of the data. Replacing the\ndenominator with the training mean, with a spec spread, or with the error of a\nmodel in production are all the same operation of changing the baseline, and the\nmetric shifts in meaning from explanatory power within this dataset to\nperformance relative to a stated reference. This document calls the forms whose\nbaseline is chosen explicitly <code>Ref_R2<\/code> and divides them into <code>R2_oos<\/code>, <code>R2_frd<\/code>,\nand <code>R2_base<\/code>. What the exchange buys is a yardstick that stops moving with the\ndataset, so lots and periods become comparable; what it costs is the\ninterpretation the standard R\u00b2 carried and the responsibility for choosing the\nreference.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">References<\/h2><a id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a id=\"user-content-ref-1\"><\/a>[1] Kv\u00e5lseth, T. O. (1985). <a href=\"https:\/\/doi.org\/10.1080\/00031305.1985.10479448\" rel=\"nofollow\">Cautionary Note about R\u00b2<\/a>. <em>The American Statistician<\/em>, 39(4), 279\u2013285. Sets out the interpretive limits the standard R\u00b2 inherits from having its denominator tied to the mean of the data, which is what makes the variants in section 3 necessary.<br>\n<a id=\"user-content-ref-2\"><\/a>[2] Campbell, J. Y., &amp; Thompson, S. B. (2008). <a href=\"https:\/\/doi.org\/10.1093\/rfs\/hhm055\" rel=\"nofollow\">Predicting Excess Stock Returns Out of Sample: Can Anything Beat the Historical Average?<\/a> <em>The Review of Financial Studies<\/em>, 21(4), 1509\u20131531. Uses an out-of-sample R\u00b2 whose denominator is fixed to the mean of the training window as its evaluation metric. It is the form section 3.1 describes, used as is.<br>\n<a id=\"user-content-ref-3\"><\/a>[3] Murphy, A. H. (1988). <a href=\"https:\/\/doi.org\/10.1175\/1520-0493%281988%29116%3C2417%3ASSBOTM%3E2.0.CO%3B2\" rel=\"nofollow\">Skill Scores Based on the Mean Square Error and Their Relationships to the Correlation Coefficient<\/a>. <em>Monthly Weather Review<\/em>, 116(12), 2417\u20132424. Formalizes the skill score as mean squared error divided by a reference error, and shows the reference may be an external value such as a historical mean. It is the basis for the structure section 2 describes.<br>\n<a id=\"user-content-ref-4\"><\/a>[4] Automotive Industry Action Group (2010). <a href=\"https:\/\/www.aiag.org\/training-and-resources\/manuals\/details\/MSA-4\" rel=\"nofollow\">Measurement Systems Analysis Reference Manual<\/a>, 4th ed. ISBN 978-1-60534-211-5. Defines the precision-to-tolerance ratio, measurement error divided by the spec tolerance, as the acceptance criterion for a measurement system. It is the <code>RMSE \/ sigma_ref<\/code> of section 3.2 as metrology uses it.<br>\n<a id=\"user-content-ref-5\"><\/a>[5] Hyndman, R. J., &amp; Koehler, A. B. (2006). <a href=\"https:\/\/doi.org\/10.1016\/j.ijforecast.2006.03.001\" rel=\"nofollow\">Another Look at Measures of Forecast Accuracy<\/a>. <em>International Journal of Forecasting<\/em>, 22(4), 679\u2013688. Sets out how dividing forecast error by the error of a persistence baseline puts different series on one scale. It is the standard example of the per-sample baseline section 3.3 covers.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>baseline model<\/strong>: the model that serves as the reference for comparison. The denominator of R\u00b2 is its sum of squared errors.<\/li>\n<li><strong>out-of-sample<\/strong>: evaluation on data that was not used for training.<\/li>\n<li><strong>persistence baseline<\/strong>: a time series baseline that uses the value at the previous step as the prediction for the next.<\/li>\n<li><strong>Referenced R\u00b2 (<code>Ref_R2<\/code>)<\/strong>: the collective name, set by this document, for an R\u00b2 computed with the baseline in its denominator stated from outside.<\/li>\n<li><strong>RMSE<\/strong>: root mean squared error, computed as <code>sqrt(SS_res \/ N)<\/code>. It returns the error to the same unit as y, so it can be set against a spec spread directly.<\/li>\n<li><strong>skill score<\/strong>: the collective name for metrics of the form <code>1 \u2212 model error \/ baseline error<\/code>. R\u00b2 is the case whose baseline is the mean.<\/li>\n<li><strong>spec tolerance<\/strong>: the spread a process spec allows. It is often used as a fixed denominator.<\/li>\n<li><strong>SS_res<\/strong>: the residual sum of squares, <code>\u03a3(y_i \u2212 y_hat_i)\u00b2<\/code>.<\/li>\n<li><strong>SS_tot<\/strong>: the total sum of squares, <code>\u03a3(y_i \u2212 y_bar)\u00b2<\/code>, which is the denominator of the standard R\u00b2.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. Reference Implementation<\/h2><a id=\"user-content-appendix-b-reference-implementation\" class=\"anchor\" aria-label=\"Permalink: Appendix B. Reference Implementation\" href=\"#appendix-b-reference-implementation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Each of the three metrics defined in section 3 is carried into one function.\n<code>r2_oos<\/code> takes <code>R2_oos<\/code> from 3.1, <code>r2_frd<\/code> takes <code>R2_frd<\/code> from 3.2, and\n<code>r2_base<\/code> takes <code>R2_base<\/code> from 3.3.<\/p>\n<p dir=\"auto\">All three receive the observations <code>y_true<\/code> and the predictions <code>y_pred<\/code> and\nreturn one skill value; the single place they differ is where the denominator\ncomes from. <code>r2_oos<\/code> receives the training mean <code>y_train_bar<\/code>, <code>r2_frd<\/code> the\nreference dispersion <code>sigma_ref<\/code>, and <code>r2_base<\/code> the baseline prediction vector\n<code>y_base<\/code>, each as an argument, and each builds its denominator from it. None of\nthe three derives the reference from <code>y_true<\/code>; all take it from outside, which\nis what section 2 called choosing the baseline explicitly, carried into code. The\nnumerator <code>SS_res<\/code> is identical for all three, so it is pulled out into\n<code>_ss_res<\/code>, which keeps the shape check and the empty-array check in one place.<\/p>\n<p dir=\"auto\">Defining <code>r2_base<\/code> first and having <code>r2_oos<\/code> call it carries the last paragraph\nof section 3.3 into code. The denominator of <code>r2_frd<\/code>, by contrast, is not the\nresidual of any prediction vector and so cannot be expressed through <code>r2_base<\/code>;\nit is computed separately.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nimport numpy as np\n\n\ndef _ss_res(y_true: np.ndarray = None, y_pred: np.ndarray = None) -&gt; float:\n    &quot;&quot;&quot;Residual sum of squares, shared by the numerator and by baseline denominators.&quot;&quot;&quot;\n    if y_true.shape != y_pred.shape:\n        raise ValueError(f&quot;shapes must match, got y_true {y_true.shape} and y_pred {y_pred.shape}.&quot;)\n    if y_true.size == 0:\n        raise ValueError(&quot;y_true is empty; a skill score needs at least one observation.&quot;)\n\n    return float(np.sum((y_true - y_pred) ** 2))\n\n\ndef r2_base(y_true: np.ndarray = None, y_pred: np.ndarray = None, y_base: np.ndarray = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.3 \u2014 skill against a baseline that answers per sample.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        y_base: baseline predictions, shape (n,), one value per sample.\n\n    Returns:\n        The skill relative to y_base. Negative when the baseline is the better predictor.\n    &quot;&quot;&quot;\n    ss_base = _ss_res(y_true=y_true, y_pred=y_base)\n    if ss_base == 0.0:\n        raise ValueError(&quot;the baseline reproduces y_true exactly, so there is no error to improve on.&quot;)\n\n    return 1.0 - _ss_res(y_true=y_true, y_pred=y_pred) \/ ss_base\n\n\ndef r2_oos(y_true: np.ndarray = None, y_pred: np.ndarray = None, y_train_bar: float = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.1 \u2014 skill against the mean that was known at training time.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        y_train_bar: mean of the training targets. Never derived from y_true, which would\n            put the test mean into the baseline and leak the evaluation set.\n\n    Returns:\n        The skill relative to always predicting y_train_bar.\n    &quot;&quot;&quot;\n    if y_train_bar is None:\n        raise ValueError(&quot;y_train_bar is required; taking the mean of y_true would leak the test set.&quot;)\n\n    y_base = np.full(shape=y_true.shape, fill_value=float(y_train_bar))\n    return r2_base(y_true=y_true, y_pred=y_pred, y_base=y_base)\n\n\ndef r2_frd(y_true: np.ndarray = None, y_pred: np.ndarray = None, sigma_ref: float = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.2 \u2014 skill against a fixed reference dispersion instead of the data spread.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        sigma_ref: reference dispersion in the unit of y, strictly positive.\n\n    Returns:\n        The skill relative to a baseline whose error scale is sigma_ref.\n        Equal to 1 - (RMSE \/ sigma_ref) ** 2.\n    &quot;&quot;&quot;\n    if sigma_ref is None or sigma_ref &lt;= 0.0:\n        raise ValueError(f&quot;sigma_ref must be a positive dispersion, got {sigma_ref}.&quot;)\n\n    # The denominator is a stated error scale, not the residual of any prediction vector,\n    # so it cannot be routed through r2_base.\n    ss_ref = float(y_true.size) * sigma_ref ** 2\n    return 1.0 - _ss_res(y_true=y_true, y_pred=y_pred) \/ ss_ref\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">numpy<\/span> <span class=\"pl-k\">as<\/span> <span class=\"pl-s1\">np<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Residual sum of squares, shared by the numerator and by baseline denominators.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span> <span class=\"pl-c1\">!=<\/span> <span class=\"pl-s1\">y_pred<\/span>.<span class=\"pl-c1\">shape<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"shapes must match, got y_true <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span><span class=\"pl-kos\">}<\/span><\/span> and y_pred <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">y_pred<\/span>.<span class=\"pl-c1\">shape<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">size<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"y_true is empty; a skill score needs at least one observation.\"<\/span>)\n\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">sum<\/span>((<span class=\"pl-s1\">y_true<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>))\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_base<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_base<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.3 \u2014 skill against a baseline that answers per sample.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        y_base: baseline predictions, shape (n,), one value per sample.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to y_base. Negative when the baseline is the better predictor.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-s1\">ss_base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_base<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">ss_base<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0.0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"the baseline reproduces y_true exactly, so there is no error to improve on.\"<\/span>)\n\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">ss_base<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_oos<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_train_bar<\/span>: <span class=\"pl-smi\">float<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.1 \u2014 skill against the mean that was known at training time.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        y_train_bar: mean of the training targets. Never derived from y_true, which would<\/span>\n<span class=\"pl-s\">            put the test mean into the baseline and leak the evaluation set.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to always predicting y_train_bar.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_train_bar<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"y_train_bar is required; taking the mean of y_true would leak the test set.\"<\/span>)\n\n    <span class=\"pl-s1\">y_base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">full<\/span>(<span class=\"pl-s1\">shape<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span>, <span class=\"pl-s1\">fill_value<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">y_train_bar<\/span>))\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">r2_base<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>, <span class=\"pl-s1\">y_base<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_base<\/span>)\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_frd<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">sigma_ref<\/span>: <span class=\"pl-smi\">float<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.2 \u2014 skill against a fixed reference dispersion instead of the data spread.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        sigma_ref: reference dispersion in the unit of y, strictly positive.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to a baseline whose error scale is sigma_ref.<\/span>\n<span class=\"pl-s\">        Equal to 1 - (RMSE \/ sigma_ref) ** 2.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span> <span class=\"pl-c1\">or<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">&lt;=<\/span> <span class=\"pl-c1\">0.0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"sigma_ref must be a positive dispersion, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">sigma_ref<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n\n    <span class=\"pl-c\"># The denominator is a stated error scale, not the residual of any prediction vector,<\/span>\n    <span class=\"pl-c\"># so it cannot be routed through r2_base.<\/span>\n    <span class=\"pl-s1\">ss_ref<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">size<\/span>) <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">ss_ref<\/span><\/pre><\/div>\n<\/article><\/div><\/div><\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-kadence-tab kt-tab-inner-content kt-inner-tab-2 kt-inner-tab6792_2b5c37-7c\"><div class=\"kt-tab-inner-content-inner\"><p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"Metrics\/R2\/R2-Denominator\/r2-denominator-ko.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">Referenced R\u00b2 \u2014 Choosing the Baseline in the R\u00b2 Denominator<\/h1><a id=\"user-content-referenced-r--choosing-the-baseline-in-the-r-denominator\" class=\"anchor\" aria-label=\"Permalink: Referenced R\u00b2 \u2014 Choosing the Baseline in the R\u00b2 Denominator\" href=\"#referenced-r--choosing-the-baseline-in-the-r-denominator\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 4 | Created: 2026-09-04 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-question\">1. Question<\/a><\/li>\n<li><a href=\"#2-structure\">2. Structure<\/a><\/li>\n<li><a href=\"#3-variants\">3. Variants<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#31-fixed-reference-point\">3.1. Fixed Reference Point<\/a><\/li>\n<li><a href=\"#32-fixed-reference-dispersion\">3.2. Fixed Reference Dispersion<\/a><\/li>\n<li><a href=\"#33-baseline-model\">3.3. Baseline Model<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#4-meaning-and-reporting\">4. Meaning and Reporting<\/a><\/li>\n<li><a href=\"#5-cautions\">5. Cautions<\/a><\/li>\n<li><a href=\"#6-summary\">6. Summary<\/a><\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-reference-implementation\">Appendix B. Reference Implementation<\/a><\/li>\n<\/ul>\n<blockquote>\n<p dir=\"auto\">\uc774 \ubb38\uc11c\ub294 \ud45c\uc900 R\u00b2 \uc758 \ubd84\ubaa8\ub97c \uc790\ub8cc\uc5d0\uc11c \uacc4\uc0b0\ud558\uc9c0 \uc54a\uace0 \ubc14\uae65\uc5d0\uc11c \uc815\ud55c \uae30\uc900\uc73c\ub85c \ubc14\uafc0 \uc218 \uc788\ub294\uc9c0,\n\uadf8\ub9ac\uace0 \uadf8\ub807\uac8c \ubc14\uafb8\uace0 \ub098\uba74 \uadf8 \uc218\uac00 \ubb34\uc5c7\uc744 \ub73b\ud558\uac8c \ub418\ub294\uc9c0\ub97c \ubb3b\ub294\ub2e4.<\/p>\n<\/blockquote>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Question<\/h2><a id=\"user-content-1-question\" class=\"anchor\" aria-label=\"Permalink: 1. Question\" href=\"#1-question\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ud45c\uc900 R\u00b2 \ub294 \ub2e4\uc74c\uacfc \uac19\uc774 \uc815\uc758\ub41c\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$R^2 = 1 - \\frac{SS_{res}}{SS_{tot}} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - \\bar{y})^2} \\hspace{19em} (1)$$<\/math-renderer><\/p>\n<p dir=\"auto\">\ubd84\ubaa8 <code>SS_tot<\/code> \ub294 \uc790\ub8cc \uc790\uc2e0\uc758 \ud3c9\uade0 <code>y_bar<\/code> \ub97c \uc911\uc2ec\uc73c\ub85c \uc7a1\uc740 \ucd1d\uc81c\uacf1\ud569\uc774\uba70, \ud754\ud788 \uc790\ub8cc\uc758 \ucd1d\uc0b0\ud3ec\ub77c\n\ubd80\ub974\ub294 \uc591\uc774\ub2e4. \uadf8 \ubd84\ubaa8\ub97c \uc790\ub8cc\uc5d0\uc11c \uacc4\uc0b0\ud558\ub294 \ub300\uc2e0 \ubc14\uae65\uc5d0\uc11c \uc815\ud55c \uac12\uc73c\ub85c \ubc14\uafc0 \uc218 \uc788\ub294\uc9c0\uac00 \uc774 \ubb38\uc11c\uc758\n\ubb3c\uc74c\uc774\ub2e4.<\/p>\n<p dir=\"auto\">\ub2f5\uc740 \ubc14\uafc0 \uc218 \uc788\ub2e4\ub294 \uac83\uc774\ub2e4. \uc6d0\ub9ac\ub85c\ub9cc \uc790\uc5f0\uc2a4\ub7ec\uc6b4 \uac83\uc774 \uc544\ub2c8\ub77c, \uc774\ubbf8 \uc790\ub9ac \uc7a1\uc740 \ud615\ud0dc\uac00 \uc5ec\ub7ff \uc788\ub2e4.\n\ub2e4\ub9cc \ubd84\ubaa8\uac00 \ubc14\ub00c\ub294 \uc21c\uac04 \uc9c0\ud45c\uc758 \ub73b\ub3c4 \ubc14\ub00c\ubbc0\ub85c, \ubb34\uc5c7\uc73c\ub85c \ubc14\uafb8\uc5c8\ub294\uc9c0\ub97c \uc5b8\uc81c\ub098 \ud568\uaed8 \ubcf4\uace0\ud574\uc57c \ud55c\ub2e4.<\/p>\n<p dir=\"auto\">\ubd84\ubaa8\ub97c \uc774\ub807\uac8c \uc815\ud574\uc11c \ub9cc\ub4e0 \uc9c0\ud45c\ub97c \uc774 \ubb38\uc11c\uc5d0\uc11c\ub294 <strong>Referenced R\u00b2<\/strong> \ub77c \ubd80\ub974\uace0 <code>Ref_R2<\/code> \ub85c \uc801\ub294\ub2e4.\nSection 3 \uc740 \ubd84\ubaa8\uc5d0 \ubb34\uc5c7\uc774 \ub4e4\uc5b4\uac00\ub294\uc9c0\ub85c \uac1c\ubcc4 \ubcc0\ud615\uc744 \ub098\ub208\ub2e4. <code>R2_oos<\/code> (out-of-sample), <code>R2_frd<\/code>\n(fixed reference dispersion), <code>R2_base<\/code> (baseline model) \uc774\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. Structure<\/h2><a id=\"user-content-2-structure\" class=\"anchor\" aria-label=\"Permalink: 2. Structure\" href=\"#2-structure\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ubd84\ubaa8\ub97c \ubc14\uafb8\uc5b4\ub3c4 \ub418\ub294 \uc774\uc720\ub294 R\u00b2 \ub97c \ub2e4\uc2dc \uc77d\uc73c\uba74 \ub4dc\ub7ec\ub09c\ub2e4. <code>SS_tot<\/code> \ub294 \uc5b8\uc81c\ub098 <code>y_bar<\/code> \ub97c \ub2f5\ud558\ub294\nmodel \uc774 \ub0a8\uae30\ub294 \uc81c\uacf1\uc624\ucc28\ud569\uacfc \uc815\ud655\ud788 \uac19\ub2e4. \uc989 R\u00b2 \ub294 \ucc98\uc74c\ubd80\ud130 \uc544\ub798\uc758 \uaf34\uc774\uc5c8\ub2e4.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"                error left by the model\nR2 = 1 -  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n            error left by a chosen baseline\"><pre lang=\"text\" class=\"notranslate\"><code>                error left by the model\nR2 = 1 -  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n            error left by a chosen baseline\n<\/code><\/pre><\/div>\n<p dir=\"auto\">\ud45c\uc900 R\u00b2 \ub294 baseline \uc744 \ud3c9\uade0\ub9cc \ub3cc\ub824\uc8fc\ub294 model \ub85c \uace0\uc815\ud55c \ud2b9\uc218\ud55c \uacbd\uc6b0\uc774\uba70, \uc774 \uad6c\uc870\ub294 skill score \ub77c\ub294\n\uc774\ub984\uc73c\ub85c \ub110\ub9ac \uc4f0\uc778\ub2e4. <strong>\ubd84\ubaa8\ub97c \uc815\ud55c\ub2e4\ub294 \uac83\uc740 baseline \uc744 \ubc14\uafb8\ub294 \uac83\uc774\uace0, \uadf8 \uc774\uc0c1\ub3c4 \uadf8 \uc774\ud558\ub3c4\n\uc544\ub2c8\ub2e4.<\/strong> \uc774 \uc0ac\uc2e4\uc774 \ubb38\uc11c\uc758 \ub098\uba38\uc9c0\ub97c \uc9c0\ubc30\ud55c\ub2e4.<\/p>\n<p dir=\"auto\">\ub530\ub77c\uc11c <code>Ref_R2<\/code> \ub294 \uc0c8\ub85c\uc6b4 \uacc4\uc0b0\uc774 \uc544\ub2c8\ub77c baseline \uc744 \uba85\uc2dc\uc801\uc73c\ub85c \uace0\ub978 R\u00b2 \uc774\uba70, \ud45c\uc900 R\u00b2 \ub294 \uadf8\nbaseline \uc744 \uc790\ub8cc\uc758 \ud3c9\uade0\uc5d0 \uc554\ubb35\uc801\uc73c\ub85c \ub454 \uacbd\uc6b0\uc774\ub2e4.<\/p>\n<p dir=\"auto\">\ubd84\uc790\uc640 \ubd84\ubaa8\uac00 \ubaa8\ub450 y \uc758 \uc81c\uacf1 \ub2e8\uc704\uc774\ubbc0\ub85c \uadf8 \ube44\ub294 \ubb34\ucc28\uc6d0\uc774\uace0, <code>Ref_R2<\/code> \ub294 baseline \uc774 \uac10\uc218\ud574\uc57c \ud588\ub358\n\uc624\ucc28 \uac00\uc6b4\ub370 model \uc774 \uc5bc\ub9c8\ub098 \ub35c\uc5b4\ub0c8\ub294\uc9c0\ub97c \ubc31\ubd84\uc728\ub85c \uc77d\ud78c\ub2e4. \uadf8 \uc77d\uae30\ub294 baseline \uc774 \ubb34\uc5c7\uc774\ub4e0 \uc131\ub9bd\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. Variants<\/h2><a id=\"user-content-3-variants\" class=\"anchor\" aria-label=\"Permalink: 3. Variants\" href=\"#3-variants\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><strong>Table 1. Ways to choose the baseline<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Symbol<\/th>\n<th>Denominator<\/th>\n<th>Baseline it encodes<\/th>\n<th>Typical use<\/th>\n<th>Reference<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>R\u00b2<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_bar)\u00b2<\/code><\/td>\n<td>\uc774 \uc790\ub8cc\uc758 \ud3c9\uade0<\/td>\n<td>\ud55c \uc790\ub8cc \uc548\uc5d0\uc11c\uc758 \uc801\ud569\ub3c4<\/td>\n<td>[<a href=\"#ref-1\">1<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_oos<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_train_bar)\u00b2<\/code><\/td>\n<td>\ud559\uc2b5 \uc2dc\uc810\uc5d0 \uc54c\ub358 \ud3c9\uade0<\/td>\n<td>Test set \ud3c9\uac00<\/td>\n<td>[<a href=\"#ref-2\">2<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_frd<\/code><\/td>\n<td><code>N \u00b7 sigma_ref\u00b2<\/code><\/td>\n<td>Spec \uc774 \ud5c8\uc6a9\ud558\ub294 \uc0b0\ud3ec<\/td>\n<td>Lot, batch, \uae30\uac04 \uc0ac\uc774\uc758 \ube44\uad50<\/td>\n<td>[<a href=\"#ref-3\">3<\/a>], [<a href=\"#ref-4\">4<\/a>]<\/td>\n<\/tr>\n<tr>\n<td><code>R2_base<\/code><\/td>\n<td><code>\u03a3(y_i \u2212 y_base_i)\u00b2<\/code><\/td>\n<td>\ud45c\ubcf8\ub9c8\ub2e4 \ub2f5\ud558\ub294 \uae30\uc900 model<\/td>\n<td>\uc2dc\uacc4\uc5f4, \uc6b4\uc601 \uc911\uc778 model \uacfc\uc758 \ube44\uad50<\/td>\n<td>[<a href=\"#ref-5\">5<\/a>]<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Reference \uc5f4\uc740 \uac01 \ud615\ud0dc\uac00 \uc2e4\uc81c\ub85c \uc4f0\uc774\ub294 \uacf3\uc744 \uac00\ub9ac\ud0a4\uba70, \uc11c\uc9c0 \uc0ac\ud56d\uc740 <a href=\"#references\">References<\/a> \uc5d0 \uc788\ub2e4.\n\ub137 \uac00\uc6b4\ub370 \uc774 \ubb38\uc11c\uac00 \uc9c0\uc5b4\ub0b8 \uacc4\uc0b0\uc740 \ud558\ub098\ub3c4 \uc5c6\uace0, \uac01\uac01\uc740 \uc790\uae30 \ubd84\uc57c\uc5d0\uc11c \uc774\ubbf8 \ud45c\uc900\uc774\ub2e4. \uc774 \ubb38\uc11c\uac00 \ub354\ud55c\n\uac83\uc740 \uc0b0\uc220\uc774 \uc544\ub2c8\ub77c \ud45c\uae30\uc774\uba70, section 4 \uac00 \uadf8 \uc774\uc57c\uae30\ub85c \ub3cc\uc544\uc628\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.1. Fixed Reference Point<\/h3><a id=\"user-content-31-fixed-reference-point\" class=\"anchor\" aria-label=\"Permalink: 3.1. Fixed Reference Point\" href=\"#31-fixed-reference-point\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\uac00\uc7a5 \ud754\ud55c \uacbd\uc6b0\uc774\ub2e4. Test set \uc744 \ud3c9\uac00\ud560 \ub54c \ubd84\ubaa8\uc758 \uae30\uc900\uc740 test \uc790\ub8cc\uc758 \ud3c9\uade0\uc774 \uc544\ub2c8\ub77c \ud559\uc2b5 \uc790\ub8cc\uc758 \ud3c9\uade0\n<code>y_train_bar<\/code> \uc5d0 \ubb36\ub294\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$R^2_{oos} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - \\bar{y}_{train})^2} \\hspace{19em} (2)$$<\/math-renderer><\/p>\n<p dir=\"auto\">\uc774\uac83\uc774 \uc633\uc740 \uaf34\uc778 \uc774\uc720\ub294 \ub458\uc774\ub2e4. \uccab\uc9f8, test \uc790\ub8cc\uc758 \ud3c9\uade0\uc740 \ud3c9\uac00 \uc2dc\uc810\uc5d0 \uc54c \uc218 \uc5c6\uc73c\ubbc0\ub85c \uadf8\uac83\uc744 baseline\n\uc5d0 \ub123\ub294 \uc77c\uc740 \ubbf8\ub798\uc5d0\uc11c \uc815\ubcf4\ub97c \ube4c\ub824\uc624\ub294 \uc148\uc774 \ub41c\ub2e4. \ub458\uc9f8, \ubd84\ubaa8\uac00 test set \uc744 \uc5b4\ub5bb\uac8c \uc798\ub790\ub294\uc9c0\uc5d0 \ub530\ub77c\n\uc6c0\uc9c1\uc5ec \uc7a3\ub300 \uc790\uccb4\uac00 \ud754\ub4e4\ub9b0\ub2e4. \ud559\uc2b5 \ud3c9\uade0\uc5d0 \ubb36\uc73c\uba74 \uc9c0\ud45c\ub294 \ud559\uc2b5 \uc911\uc5d0 \uc54c\ub358 \ud3c9\uade0\uc744 \uacc4\uc18d \ub3cc\ub824\uc8fc\ub294 model\n\ubcf4\ub2e4 \uc5bc\ub9c8\ub098 \ub098\uc544\uc84c\ub294\uac00 \ud558\ub294 \ubb3c\uc74c\uc774 \ub418\uace0, \uc790\ub8cc\ub97c \uc5b4\ub5bb\uac8c \ub098\ub204\ub4e0 \uc7a3\ub300\uac00 \uc720\uc9c0\ub41c\ub2e4.<\/p>\n<p dir=\"auto\">\uc774 \ud615\ud0dc\ub294 \ubc14\uae65\uc5d0\uc11c out-of-sample R\u00b2 \ub85c \uc54c\ub824\uc838 \uc788\uc73c\ubbc0\ub85c, \uc678\ubd80 \ubcf4\uace0\uc5d0\ub294 \uadf8 \uc774\ub984\uc744 \uc4f4\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.2. Fixed Reference Dispersion<\/h3><a id=\"user-content-32-fixed-reference-dispersion\" class=\"anchor\" aria-label=\"Permalink: 3.2. Fixed Reference Dispersion\" href=\"#32-fixed-reference-dispersion\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ubd84\ubaa8\ub97c \uc790\ub8cc\uc5d0\uc11c \uacc4\uc0b0\ud558\uc9c0 \uc54a\uace0 \uc774\ubbf8 \uc54c\uace0 \uc788\ub294 \uae30\uc900 \ubd84\uc0b0\uc73c\ub85c \ubc14\uafbc\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$R^2_{frd} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{N \\cdot \\sigma_{ref}^2} \\hspace{19em} (3)$$<\/math-renderer><\/p>\n<p dir=\"auto\"><code>sigma_ref<\/code> \uc5d0\ub294 \uacf5\uc815 spec \uc774 \ud5c8\uc6a9\ud558\ub294 \uc0b0\ud3ec, \uc313\uc544 \uc628 \uc774\ub825 \uc790\ub8cc\uc758 \ubd84\uc0b0, \uacc4\uce21 system \uc758 \uae30\uc900 \ubd84\uc0b0\n\uac19\uc740 \ub3c4\uba54\uc778 \uae30\uc900\uc744 \uc4f4\ub2e4. \ub450\uaed8 \uc608\uce21\uc774\ub77c\uba74 \ud574\ub2f9 \uce35\uc758 \uad00\ub9ac spec \uc0b0\ud3ec\ub97c \ubd84\ubaa8\uc5d0 \ub123\ub294 \uac83\uc73c\ub85c \uc9c0\ud45c\ub294\n\uace0\uc815\ub41c \uc7a3\ub300\uc5d0 \uacac\uc900 model \uc758 \ucc99\ub3c4\uac00 \ub41c\ub2e4.<\/p>\n<p dir=\"auto\">\ubd84\ubaa8\uac00 \uc0c1\uc218\uc774\ubbc0\ub85c \uc2dd\uc740 \ud55c \ub2e8\uacc4 \ub354 \uc904\uc5b4\ub4e0\ub2e4. \ubd84\uc790 <code>SS_res<\/code> \ub97c \ud45c\ubcf8 \uc218 <code>N<\/code> \uc73c\ub85c \ub098\ub208 \uac83\uc758 \uc81c\uacf1\uadfc\uc774\nroot mean squared error, \uace7 RMSE \uc774\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$\\mathrm{RMSE} = \\sqrt{\\frac{SS_{res}}{N}} \\hspace{19em} (4)$$<\/math-renderer><\/p>\n<p dir=\"auto\">RMSE \ub294 \uc624\ucc28\ub97c y \uc640 \uac19\uc740 \ub2e8\uc704\ub85c \ub3cc\ub824\ub193\uc73c\ubbc0\ub85c <code>sigma_ref<\/code> \ub85c \ubc14\ub85c \ub098\ub20c \uc218 \uc788\ub2e4. <code>SS_res<\/code> \uc5d0\n<code>N \u00b7 RMSE\u00b2<\/code> \ub97c \ub123\uc73c\uba74 <code>N<\/code> \uc774 \uc57d\ubd84\ub418\uace0 \uc544\ub798\ub9cc \ub0a8\ub294\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$R^2_{frd} = 1 - \\left(\\frac{\\mathrm{RMSE}}{\\sigma_{ref}}\\right)^2 \\hspace{19em} (5)$$<\/math-renderer><\/p>\n<p dir=\"auto\">\uc774\uac83\uc774 \uc774 \ubcc0\ud615\uc758 \ubb3c\ub9ac\uc801 \uc758\ubbf8\uc774\ub2e4. <code>R2_frd<\/code> \ub294 <strong>model \uc758 \uc624\ucc28\uac00 spec \uc0b0\ud3ec\uc758 \uba87 \ubc30\uc778\uc9c0\ub97c \uc7ac\uc5b4<\/strong> \uadf8\uac83\uc744\n1 \uc5d0\uc11c \ube80\ub2e4. Spec \uc758 \uc808\ubc18\uc774\uba74 0.75, spec \uacfc \uac19\uc740 \uc624\ucc28\uba74 0, spec \uc744 \ub118\ub294 \uc624\ucc28\uba74 \uc74c\uc218\uac00 \ub41c\ub2e4. Baseline\n\uc758 \ub9d0\ub85c \uc62e\uae30\uba74 \uae30\uc900\uc740 spec \uc774 \ud5c8\uc6a9\ud558\ub294 \ub9cc\ud07c\uc758 \uc624\ucc28\ub97c \ub0b4\ub294 \uac00\uc0c1\uc758 model \uc774\uace0, \ubb3c\uc74c\uc740 \uadf8\uac83\uc744 model \uc774\n\uc774\uacbc\ub294\uac00\uc774\ub2e4.<\/p>\n<p dir=\"auto\">\uacc4\uce21 \ubd84\uc57c\uc5d0\ub294 \uc624\ucc28\uc640 spec \uc758 \ube44\ub97c R\u00b2 \ub85c \uafb8\ubbf8\uc9c0 \uc54a\uace0 \uadf8\ub300\ub85c \ubcf4\uace0\ud558\ub294 \uad00\ud589\uc774 \uc788\ub2e4. \uc77d\ub294 \uc774\uac00 \uacf5\uc815\uc774\ub098\n\uacc4\uce21 engineer \ub77c\uba74 <code>RMSE \/ sigma_ref<\/code> \ub97c \uadf8\ub300\ub85c \uac74\ub124\ub294 \ud3b8\uc774 \uc798 \ud1b5\ud558\uace0, \uadf8 \uc218\uac00 \ub2e4\ub978 \uc9c0\ud45c\ub4e4\uacfc \ud55c \ud45c\uc5d0\n\uc549\uc544\uc57c \ud55c\ub2e4\uba74 <code>R2_frd<\/code> \ub85c \ubc14\uafb8\uc5b4 0 \uacfc 1 \uc0ac\uc774\uc758 \ucc99\ub3c4\uc5d0 \uc62c\ub9b0\ub2e4. \ub458\uc740 \uc704 \uc2dd\uc73c\ub85c \uc11c\ub85c \ubcc0\ud658\ub418\ubbc0\ub85c \uac19\uc740\n\uc815\ubcf4\ub97c \uc9c0\ub2cc\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.3. Baseline Model<\/h3><a id=\"user-content-33-baseline-model\" class=\"anchor\" aria-label=\"Permalink: 3.3. Baseline Model\" href=\"#33-baseline-model\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 3.1 \uc758 baseline \uc740 \uc5b4\ub5a4 \ud45c\ubcf8\uc744 \ub9cc\ub098\ub4e0 <code>y_train_bar<\/code> \ub77c\ub294 \uc218 \ud558\ub098\ub85c \ub2f5\ud558\uace0, section 3.2 \uc758\nbaseline \uc740 \uc5b4\ub5a4 \ud45c\ubcf8\uc744 \ub9cc\ub098\ub4e0 <code>sigma_ref<\/code> \ub9cc\ud07c\uc758 \uc624\ucc28\ub97c \ub0b8\ub2e4. \ub458 \ub2e4 \uae30\uc900\uc774 \ud45c\ubcf8\uc5d0 \ub530\ub77c \ubcc0\ud558\uc9c0 \uc54a\ub294\n\uc0c1\uc218 baseline \uc774\ub2e4.<\/p>\n<p dir=\"auto\">\uae30\uc900 \uc790\uccb4\uac00 \ud45c\ubcf8\ub9c8\ub2e4 \ub2ec\ub77c\uc838\uc57c \ud558\ub294 \uacbd\uc6b0\ub294 \uadf8 \uaf34\ub85c \uc801\uc744 \uc218 \uc5c6\ub2e4. \uadf8\ub54c baseline \uc740 \uac01 i \ub9c8\ub2e4 \uc790\uae30 \uac12\n<code>y_base_i<\/code> \ub97c \uac00\uc9c4\ub2e4.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"9d4dce558a9ddae831ac90056dec7127\">$$R^2_{base} = 1 - \\frac{\\sum_i (y_i - \\hat{y}_i)^2}{\\sum_i (y_i - y_{base,i})^2} \\hspace{19em} (6)$$<\/math-renderer><\/p>\n<p dir=\"auto\">\uc2dc\uacc4\uc5f4\uc758 persistence baseline \uc774 \ub300\ud45c\uc801\uc778 \uacbd\uc6b0\uc774\ub2e4. \uc9c1\uc804 \ub2e8\uacc4\uc758 \uac12\uc744 \ub2e4\uc74c \ub2e8\uacc4\uc758 \uc608\uce21\uc73c\ub85c \uc4f0\ubbc0\ub85c\n<code>y_base_i<\/code> \uac00 i \ub9c8\ub2e4 \ub2e4\ub974\uace0, \uc5b4\ub5a4 \uc0c1\uc218\ub85c\ub3c4 \uac19\uc740 \ubd84\ubaa8\ub97c \ub9cc\ub4e4 \uc218 \uc5c6\ub2e4. \uacc4\uc808 \ud3c9\uade0\uc744 baseline \uc73c\ub85c \uc0bc\uc744\n\ub54c\ub3c4, \uc6b4\uc601 \uc911\uc778 model \uc744 baseline \uc73c\ub85c \uc0bc\uc544 \uad50\uccb4\uc758 \uac00\uce58\ub97c \uc7b4 \ub54c\ub3c4 \ub9c8\ucc2c\uac00\uc9c0\uc774\ub2e4.<\/p>\n<p dir=\"auto\"><code>y_base_i<\/code> \ub97c \uc0c1\uc218 <code>y_train_bar<\/code> \ub85c \ub450\uba74 \uc774\uac83\uc740 section 3.1 \ub85c \uc904\uc5b4\ub4e4\ubbc0\ub85c, \uadf8 \uc808\uc740 \uc774 \uc808\uc758 \ud2b9\uc218\ud55c\n\uacbd\uc6b0\uc774\ub2e4. \uadf8\ub7f0\ub370\ub3c4 \ub530\ub85c \ub450\ub294 \uac83\uc740 \ub458\uc774 \ub2e4\ub978 \ubb3c\uc74c\uc5d0 \ub2f5\ud558\uae30 \ub54c\ubb38\uc774\ub2e4. Section 3.1 \uc740 model \uc774 \ud3c9\uade0\uc744\n\uc774\uae30\ub294\uc9c0\ub97c \ubb3b\uace0, section 3.3 \uc740 \uc774\ubbf8 \uc4f0\uace0 \uc788\ub294 \uac83\uc744 \uc774\uae30\ub294\uc9c0\ub97c \ubb3b\ub294\ub2e4. \uc55e\uc758 \ubb3c\uc74c\uc740 model \uc774 \uac12\uc5b4\uce58\uac00\n\uc788\ub294\uc9c0\ub97c \uc815\ud558\uace0, \ub4a4\uc758 \ubb3c\uc74c\uc740 \uadf8\uac83\uc774 \uad50\uccb4\ud560 \uac12\uc5b4\uce58\uac00 \uc788\ub294\uc9c0\ub97c \uc815\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">4. Meaning and Reporting<\/h2><a id=\"user-content-4-meaning-and-reporting\" class=\"anchor\" aria-label=\"Permalink: 4. Meaning and Reporting\" href=\"#4-meaning-and-reporting\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ud83d\udca1 \ubd84\ubaa8\ub97c \uace0\uc815\ud558\ub294 \uc9c4\uc9dc \uc774\uc720\ub294 \ud3b8\uc758\uac00 \uc544\ub2c8\ub77c <strong>\ud45c\uc900 R\u00b2 \ub85c\ub294 \uc790\ub8cc \uc0ac\uc774\ub97c \ube44\uad50\ud560 \uc218 \uc5c6\ub2e4\ub294<\/strong> \ub370 \uc788\ub2e4.\n\ubd84\ubaa8\ub294 \uc790\ub8cc\ub9c8\ub2e4 \ub2e4\uc2dc \uacc4\uc0b0\ub418\ubbc0\ub85c \uc7a3\ub300\uac00 \uc790\ub8cc\ub97c \ub530\ub77c \ubc14\ub010\ub2e4.<\/p>\n<p dir=\"auto\">\ud55c model \uc744 \uc138 lot \uc5d0 \uc801\uc6a9\ud574 \uc14b \ubaa8\ub450\uc5d0\uc11c RMSE \uac00 0.5 nm \ub85c \uac19\uc740 \uacbd\uc6b0\ub97c \ubcf4\uba74 \ubb38\uc81c\uac00 \ub69c\ub837\ud558\ub2e4.<\/p>\n<p dir=\"auto\"><strong>Table 2. The same model on three lots, RMSE fixed at 0.5 nm<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Lot<\/th>\n<th>Lot dispersion (nm)<\/th>\n<th>Standard R\u00b2<\/th>\n<th><code>R2_frd<\/code> against a spec of 1.0 nm<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>2.0<\/td>\n<td>0.9375<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>1.2<\/td>\n<td>0.8264<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>0.6<\/td>\n<td>0.3056<\/td>\n<td>0.7500<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Model \uc758 \uc608\uce21 \uc624\ucc28\ub294 \uc138 lot \uc5d0\uc11c \uac19\uc740\ub370 \ud45c\uc900 R\u00b2 \ub294 0.94 \uc5d0\uc11c 0.31 \uae4c\uc9c0 \ubc8c\uc5b4\uc9c4\ub2e4. \ubc14\ub010 \uac83\uc740 \ubd84\ubaa8\uc774\uc9c0\nmodel \uc774 \uc544\ub2c8\ub2e4. \uc0b0\ud3ec\uac00 \ud070 lot \uc740 baseline \uc774 \uc774\ubbf8 \uc2e4\ud328\ud558\uace0 \uc788\ub358 lot \uc774\ubbc0\ub85c \uac19\uc740 \uc131\ub2a5\uc774 \uc88b\uc544 \ubcf4\uc774\uace0,\n\uc0b0\ud3ec\uac00 \uc791\uc740 lot \uc740 baseline \uc774 \uc774\ubbf8 \uac10\ub2f9\ud558\ub358 lot \uc774\ubbc0\ub85c \uac19\uc740 \uc131\ub2a5\uc774 \ub098\ube60 \ubcf4\uc778\ub2e4. \ud45c\uc900 R\u00b2 \ub294 \uc774\uac83\uc744\n\uc815\uc9c1\ud558\uac8c \ubcf4\uace0\ud558\uace0 \uc788\uc744 \ubfd0\uc774\uba70, \uc774 \uac12\uc73c\ub85c lot \uc744 \uc904 \uc138\uc6b0\uba74 model \uc774 \uc544\ub2c8\ub77c lot \uc758 \uc0b0\ud3ec\ub97c \uc904 \uc138\uc6b0\uac8c\n\ub41c\ub2e4.<\/p>\n<p dir=\"auto\">\ubd84\ubaa8\ub97c 1.0 nm \ub85c \uace0\uc815\ud558\uba74 \uc14b \ubaa8\ub450 0.75 \uac00 \ub418\uace0, \uc9c0\ud45c\ub294 \uadf8\ub54c model \uc758 \uc131\ub2a5\ub9cc\uc744 \ube44\ucd98\ub2e4. \ub2ec\ub9ac \ub9d0\ud558\uba74 \ub450\n\uc9c0\ud45c\ub294 \ub2e4\ub978 \ubb3c\uc74c\uc5d0 \ub2f5\ud55c\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li>\ud45c\uc900 R\u00b2 \u2014 \uc774 \uc790\ub8cc \uc548\uc5d0\uc11c model \uc774 \ud3c9\uade0\ubcf4\ub2e4 \uc5bc\ub9c8\ub098 \ub098\uc740\uac00. \uc7a3\ub300\uac00 \uc790\ub8cc\ub9c8\ub2e4 \ub2e4\ub974\ub2e4.<\/li>\n<li><code>R2_frd<\/code> \u2014 model \uc774 \uc815\ud574 \ub454 \uc7a3\ub300\ubcf4\ub2e4 \uc5bc\ub9c8\ub098 \ub098\uc740\uac00. \uc790\ub8cc \uc0ac\uc774\ub97c \ube44\uad50\ud560 \uc218 \uc788\ub2e4.<\/li>\n<\/ul>\n<p dir=\"auto\">\uc5b4\ub290 \ucabd\uc774 \uc633\uc740\uc9c0\ub294 \ubb3c\uc74c\uc774 \uc815\ud55c\ub2e4. \uc774 lot \uc774 \uc5bc\ub9c8\ub098 \uc124\uba85\ub418\uc5c8\ub294\uac00\ub97c \ubb3b\ub294\ub2e4\uba74 \ud45c\uc900 R\u00b2 \uc774\uace0, model \uc744\nline \uc804\uccb4\uc5d0 \ubc30\ud3ec\ud560 \uc218 \uc788\ub294\uac00\ub97c \ubb3b\ub294\ub2e4\uba74 <code>R2_frd<\/code> \uc774\ub2e4.<\/p>\n<p dir=\"auto\">\uadf8\ub7ec\ubbc0\ub85c \uac12 \ud558\ub098\ub9cc \uac74\ub124\ub294 \uac83\uc73c\ub85c\ub294 \ubaa8\uc790\ub780\ub2e4. \ub450 \ubb3c\uc74c\uc758 \ub2f5\uc774 \uac19\uc740 \uc790\ub9ac\uc5d0 \uac19\uc740 \uaf34\ub85c \ub0b4\ub824\uc549\uc73c\ubbc0\ub85c \ubc1b\ub294\n\uc774\ub294 \uc5b4\ub290 \ucabd\uc744 \ubcf8 \uac83\uc778\uc9c0 \uc54c \uc218 \uc5c6\ub2e4. \ubcf4\uace0\ub294 \uc544\ub798 \uaddc\uce59\uc744 \ub530\ub978\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li><code>R\u00b2<\/code> \uc790\uccb4\uac00 \uc544\ub2c8\ub77c \ubcc0\ud615\uc5d0 \ub9de\ub294 \uae30\ud638\ub97c \uc4f4\ub2e4. \uac19\uc740 \uae30\ud638\ub294 \uc77d\ub294 \uc774\uc5d0\uac8c \ud45c\uc900 R\u00b2 \ub85c \ubc1b\uc544\ub4e4\uc774\ub77c\uace0 \uad8c\ud55c\ub2e4.<\/li>\n<li>\uae30\ud638\ub9cc\uc73c\ub85c\ub294 \ucda9\ubd84\ud788 \uc2e4\ub9ac\uc9c0 \uc54a\uc73c\ubbc0\ub85c, \ubd84\ubaa8\uc758 \uae30\uc900\uc744 \uac12\uacfc \ucd9c\ucc98\uc640 \ud568\uaed8 \uc801\ub294\ub2e4. \uc218\ub9cc \uc801\uc9c0 \ub9d0\uace0 <code>R2_frd = 0.75 (reference: spec tolerance sigma = 1.0 nm)<\/code> \ub85c \uc801\ub294\ub2e4.<\/li>\n<li>\ud45c\uc900 R\u00b2 \ub97c \ub098\ub780\ud788 \ubcf4\uace0\ud55c\ub2e4. \ub458 \uc0ac\uc774\uc758 \uac04\uaca9\uc774\uc57c\ub9d0\ub85c \uadf8 \uc790\ub8cc\uc758 \uc0b0\ud3ec\uac00 spec \uc5d0 \uacac\uc8fc\uc5b4 \uc5b4\ub290 \ucabd\uc73c\ub85c \uae30\uc6b8\uc5b4 \uc788\ub294\uc9c0\ub97c \uc77d\ub294 \uc774\uc5d0\uac8c \ub9d0\ud574 \uc900\ub2e4.<\/li>\n<li><code>sigma_ref<\/code> \ub97c \uadf8\ub807\uac8c \uace0\ub978 \uadfc\uac70\ub97c \ub0a8\uae34\ub2e4. \uadfc\uac70 \uc5c6\uc774 \uace0\ub978 \ubd84\ubaa8\ub294 \uc9c0\ud45c \uc804\uccb4\ub97c \uc790\uc758\uc801\uc73c\ub85c \ub9cc\ub4e0\ub2e4.<\/li>\n<\/ul>\n<p dir=\"auto\"><code>Ref_R2<\/code>, <code>R2_frd<\/code>, <code>R2_base<\/code> \ub294 \uc774 \ubb38\uc11c\uac00 \uc815\ud55c \uc774\ub984\uc774\uba70 \ubb38\uc11c \ubc16\uc5d0\uc11c\ub294 \ud1b5\ud558\uc9c0 \uc54a\ub294\ub2e4. \ubc16\uc73c\ub85c \ubcf4\ub0bc\n\ub54c\ub294 \uae30\ud638 \ub4a4\uc5d0 \ud55c \uc904\uc9dc\ub9ac \uc815\uc758\ub97c \ubd99\uc774\uac70\ub098, section 3.1 \ucc98\ub7fc \uc774\ubbf8 \uc790\ub9ac \uc7a1\uc740 \uc774\ub984\uc774 \uc788\uc73c\uba74 \uadf8\uac83\uc744 \uc4f4\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">5. Cautions<\/h2><a id=\"user-content-5-cautions\" class=\"anchor\" aria-label=\"Permalink: 5. Cautions\" href=\"#5-cautions\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>\uc74c\uc218\uac00 \ub098\uc628\ub2e4.<\/strong> Model \uc774 baseline \ubcf4\ub2e4 \ub098\uc058\uba74 <code>SS_res<\/code> \uac00 \ubd84\ubaa8\ub97c \ub118\uc5b4 \uac12\uc774 0 \uc544\ub798\ub85c \ub0b4\ub824\uac04\ub2e4. Spec \uc774 1.0 nm \uc77c \ub54c RMSE \uac00 1.3 nm \uc774\uba74 \u22120.69 \uac00 \ub41c\ub2e4. \uc774\uac83\uc740 \uc624\ub958\uac00 \uc544\ub2c8\ub77c baseline \uc744 \uc4f0\ub294 \ud3b8\uc774 \ub0ab\ub2e4\ub294 \uc815\uc0c1\uc801\uc778 \uc2e0\ud638\uc774\uba70, out-of-sample \ud3c9\uac00\uc5d0\uc11c \ud754\ud558\ub2e4.<\/li>\n<li><strong>\ubd84\ubaa8\uac00 \uc791\uc73c\uba74 \uac12\uc774 \ud3ed\ubc1c\ud55c\ub2e4.<\/strong> Spec \uc0b0\ud3ec\uac00 \uc544\uc8fc \uc791\uc740 \ud56d\ubaa9\uc5d0 \uc774 \uc9c0\ud45c\ub97c \uc4f0\uba74 \uc791\uc740 \uc624\ucc28\uc5d0\uc11c \ud070 \uc74c\uc218\uac00 \ub098\uc628\ub2e4. \uadf8\ub7f0 \ud56d\ubaa9\uc740 R\u00b2 \uacc4\uc5f4\uc758 \ubb34\uc5c7\ubcf4\ub2e4 \uc624\ucc28\uc758 \uc808\ub300 \ud06c\uae30\ub85c \uad00\ub9ac\ud558\ub294 \ud3b8\uc774 \ub0ab\ub2e4.<\/li>\n<li><strong>\uc704 \ud55c\uacc4\ub294 \uc5ec\uc804\ud788 1 \uc774\ub2e4.<\/strong> \ubd84\ubaa8\ub97c \ubc14\uafb8\uc5b4\ub3c4 <code>SS_res<\/code> \ub97c 0 \uc544\ub798\ub85c \ub0b4\ub9b4 \uc218\ub294 \uc5c6\uc73c\ubbc0\ub85c \uac12\uc774 1 \uc744 \ub118\uc9c0 \uc54a\ub294\ub2e4. 1 \uc5d0 \uac00\uae4c\uc6b4 \uac12\uc740 model \uc774 \uc644\ubcbd\ud558\ub2e4\ub294 \ub73b\uc774 \uc544\ub2c8\ub77c \uc815\ud574 \ub454 baseline \uc774 \uc555\ub3c4\ub418\uc5c8\ub2e4\ub294 \ub73b\uc774\ub2e4.<\/li>\n<li><strong>\ubd84\ubaa8\ub294 \uc0ac\ud6c4\uc5d0 \uace0\ub974\uc9c0 \uc54a\ub294\ub2e4.<\/strong> \uacb0\uacfc\ub97c \ubcf8 \ub4a4 \uc720\ub9ac\ud55c <code>sigma_ref<\/code> \ub97c \uace0\ub974\uba74 \uc9c0\ud45c\ub294 \uc218\uc0ac\uac00 \ub41c\ub2e4. \uae30\uc900\uc740 \ud3c9\uac00 \uc804\uc5d0 \uc815\ud558\uace0 \uae30\ub85d\ud55c\ub2e4.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">6. Summary<\/h2><a id=\"user-content-6-summary\" class=\"anchor\" aria-label=\"Permalink: 6. Summary\" href=\"#6-summary\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">R\u00b2 \uc758 \ubd84\ubaa8\ub294 baseline \uc758 \uc624\ucc28\uc774\uace0, \ud45c\uc900 R\u00b2 \ub294 \uadf8 baseline \uc744 \uc790\ub8cc\uc758 \ud3c9\uade0\uc73c\ub85c \uace0\uc815\ud55c \ud2b9\uc218\ud55c \uacbd\uc6b0\uc774\ub2e4.\n\ubd84\ubaa8\ub97c \ud559\uc2b5 \ud3c9\uade0\uc73c\ub85c, spec \uc0b0\ud3ec\ub85c, \uc6b4\uc601 \uc911\uc778 model \uc758 \uc624\ucc28\ub85c \ubc14\uafb8\ub294 \uc77c\uc740 \ubaa8\ub450 baseline \uc744 \ubc14\uafb8\ub294 \uac19\uc740\n\uc870\uc791\uc774\uba70, \uc9c0\ud45c\uc758 \ub73b\uc740 \uc774 \uc790\ub8cc \uc548\uc5d0\uc11c\uc758 \uc124\uba85\ub825\uc5d0\uc11c \uc815\ud574 \ub454 \uae30\uc900\uc5d0 \uacac\uc900 \uc131\ub2a5\uc73c\ub85c \uc62e\uaca8 \uac04\ub2e4. \uc774 \ubb38\uc11c\ub294\nbaseline \uc744 \uba85\uc2dc\uc801\uc73c\ub85c \uace0\ub978 \ud615\ud0dc\ub4e4\uc744 <code>Ref_R2<\/code> \ub77c \ubd80\ub974\uace0 <code>R2_oos<\/code>, <code>R2_frd<\/code>, <code>R2_base<\/code> \ub85c \ub098\ub208\ub2e4. \uc774\n\uad50\ud658\uc73c\ub85c \uc5bb\ub294 \uac83\uc740 \uc790\ub8cc\ub97c \ub530\ub77c \uc6c0\uc9c1\uc774\uc9c0 \uc54a\ub294 \uc7a3\ub300\uc5ec\uc11c lot \uacfc \uae30\uac04\uc774 \ube44\uad50 \uac00\ub2a5\ud574\uc9c0\ub294 \uac83\uc774\uace0, \uc783\ub294\n\uac83\uc740 \ud45c\uc900 R\u00b2 \uac00 \uc9c0\ub2c8\ub358 \ud574\uc11d\uacfc \uae30\uc900\uc744 \uace0\ub974\ub294 \ucc45\uc784\uc774\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">References<\/h2><a id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a id=\"user-content-ref-1\"><\/a>[1] Kv\u00e5lseth, T. O. (1985). <a href=\"https:\/\/doi.org\/10.1080\/00031305.1985.10479448\" rel=\"nofollow\">Cautionary Note about R\u00b2<\/a>. <em>The American Statistician<\/em>, 39(4), 279\u2013285. \ud45c\uc900 R\u00b2 \uac00 \ubd84\ubaa8\ub97c \uc790\ub8cc\uc758 \ud3c9\uade0\uc5d0 \ubb36\uc5b4 \ub454 \ub370\uc11c \ubb3c\ub824\ubc1b\ub294 \ud574\uc11d\uc758 \ud55c\uacc4\ub97c \ubc1d\ud788\uba70, section 3 \uc758 \ubcc0\ud615\ub4e4\uc774 \ud544\uc694\ud55c \uc774\uc720\uac00 \ub41c\ub2e4.<br>\n<a id=\"user-content-ref-2\"><\/a>[2] Campbell, J. Y., &amp; Thompson, S. B. (2008). <a href=\"https:\/\/doi.org\/10.1093\/rfs\/hhm055\" rel=\"nofollow\">Predicting Excess Stock Returns Out of Sample: Can Anything Beat the Historical Average?<\/a> <em>The Review of Financial Studies<\/em>, 21(4), 1509\u20131531. \ubd84\ubaa8\ub97c \ud559\uc2b5 \uad6c\uac04\uc758 \ud3c9\uade0\uc5d0 \uace0\uc815\ud55c out-of-sample R\u00b2 \ub97c \ud3c9\uac00 \uc9c0\ud45c\ub85c \uc4f4\ub2e4. Section 3.1 \uc774 \uae30\uc220\ud558\ub294 \ud615\ud0dc\ub97c \uadf8\ub300\ub85c \uc4f4 \uac83\uc774\ub2e4.<br>\n<a id=\"user-content-ref-3\"><\/a>[3] Murphy, A. H. (1988). <a href=\"https:\/\/doi.org\/10.1175\/1520-0493%281988%29116%3C2417%3ASSBOTM%3E2.0.CO%3B2\" rel=\"nofollow\">Skill Scores Based on the Mean Square Error and Their Relationships to the Correlation Coefficient<\/a>. <em>Monthly Weather Review<\/em>, 116(12), 2417\u20132424. Skill score \ub97c \ud3c9\uade0\uc81c\uacf1\uc624\ucc28\ub97c \uae30\uc900 \uc624\ucc28\ub85c \ub098\ub208 \uac83\uc73c\ub85c \uc815\uc2dd\ud654\ud558\uace0, \uadf8 \uae30\uc900\uc774 \uacfc\uac70 \ud3c9\uade0 \uac19\uc740 \uc678\ubd80 \uac12\uc77c \uc218 \uc788\uc74c\uc744 \ubcf4\uc778\ub2e4. Section 2 \uac00 \uae30\uc220\ud558\ub294 \uad6c\uc870\uc758 \uadfc\uac70\uc774\ub2e4.<br>\n<a id=\"user-content-ref-4\"><\/a>[4] Automotive Industry Action Group (2010). <a href=\"https:\/\/www.aiag.org\/training-and-resources\/manuals\/details\/MSA-4\" rel=\"nofollow\">Measurement Systems Analysis Reference Manual<\/a>, 4th ed. ISBN 978-1-60534-211-5. \uacc4\uce21 \uc624\ucc28\ub97c spec tolerance \ub85c \ub098\ub208 precision-to-tolerance ratio \ub97c \uacc4\uce21 system \uc758 \ud569\uaca9 \uae30\uc900\uc73c\ub85c \uc815\uc758\ud55c\ub2e4. Section 3.2 \uc758 <code>RMSE \/ sigma_ref<\/code> \ub97c \uacc4\uce21 \ubd84\uc57c\uac00 \uc4f0\ub294 \ubc29\uc2dd\uc774\ub2e4.<br>\n<a id=\"user-content-ref-5\"><\/a>[5] Hyndman, R. J., &amp; Koehler, A. B. (2006). <a href=\"https:\/\/doi.org\/10.1016\/j.ijforecast.2006.03.001\" rel=\"nofollow\">Another Look at Measures of Forecast Accuracy<\/a>. <em>International Journal of Forecasting<\/em>, 22(4), 679\u2013688. \uc608\uce21 \uc624\ucc28\ub97c persistence baseline \uc758 \uc624\ucc28\ub85c \ub098\ub204\uba74 \uc11c\ub85c \ub2e4\ub978 \uacc4\uc5f4\uc774 \ud55c \ucc99\ub3c4\uc5d0 \ub193\uc778\ub2e4\ub294 \uac83\uc744 \ubc1d\ud78c\ub2e4. Section 3.3 \uc774 \ub2e4\ub8e8\ub294 \ud45c\ubcf8\ubcc4 baseline \uc758 \ud45c\uc900\uc801\uc778 \uc608\uc774\ub2e4.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>baseline model<\/strong>: \ube44\uad50\uc758 \uae30\uc900\uc774 \ub418\ub294 model. R\u00b2 \uc758 \ubd84\ubaa8\ub294 \uadf8 \uc81c\uacf1\uc624\ucc28\ud569\uc774\ub2e4.<\/li>\n<li><strong>out-of-sample<\/strong>: \ud559\uc2b5\uc5d0 \uc4f0\uc9c0 \uc54a\uc740 \uc790\ub8cc\uc5d0\uc11c\uc758 \ud3c9\uac00.<\/li>\n<li><strong>persistence baseline<\/strong>: \uc9c1\uc804 \ub2e8\uacc4\uc758 \uac12\uc744 \ub2e4\uc74c \ub2e8\uacc4\uc758 \uc608\uce21\uc73c\ub85c \uc4f0\ub294 \uc2dc\uacc4\uc5f4 baseline.<\/li>\n<li><strong>Referenced R\u00b2 (<code>Ref_R2<\/code>)<\/strong>: \ubd84\ubaa8\uc758 baseline \uc744 \ubc14\uae65\uc5d0\uc11c \uc815\ud574 \uacc4\uc0b0\ud55c R\u00b2 \ub97c \uc774 \ubb38\uc11c\uc5d0\uc11c \ud1b5\uce6d\ud558\ub294 \uc774\ub984.<\/li>\n<li><strong>RMSE<\/strong>: root mean squared error \uc774\uba70 <code>sqrt(SS_res \/ N)<\/code> \ub85c \uacc4\uc0b0\ud55c\ub2e4. \uc624\ucc28\ub97c y \uc640 \uac19\uc740 \ub2e8\uc704\ub85c \ub3cc\ub824\ub193\uc73c\ubbc0\ub85c spec \uc0b0\ud3ec\uc5d0 \ubc14\ub85c \uacac\uc904 \uc218 \uc788\ub2e4.<\/li>\n<li><strong>skill score<\/strong>: <code>1 \u2212 model error \/ baseline error<\/code> \uaf34 \uc9c0\ud45c\ub4e4\uc758 \ud1b5\uce6d. R\u00b2 \ub294 baseline \uc774 \ud3c9\uade0\uc778 \uacbd\uc6b0\uc774\ub2e4.<\/li>\n<li><strong>spec tolerance<\/strong>: \uacf5\uc815 spec \uc774 \ud5c8\uc6a9\ud558\ub294 \uc0b0\ud3ec. \uace0\uc815 \ubd84\ubaa8\ub85c \uc790\uc8fc \uc4f0\uc778\ub2e4.<\/li>\n<li><strong>SS_res<\/strong>: \uc794\ucc28\uc81c\uacf1\ud569 <code>\u03a3(y_i \u2212 y_hat_i)\u00b2<\/code>.<\/li>\n<li><strong>SS_tot<\/strong>: \ucd1d\uc81c\uacf1\ud569 <code>\u03a3(y_i \u2212 y_bar)\u00b2<\/code> \uc774\uba70, \ud45c\uc900 R\u00b2 \uc758 \ubd84\ubaa8\uc774\ub2e4.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. Reference Implementation<\/h2><a id=\"user-content-appendix-b-reference-implementation\" class=\"anchor\" aria-label=\"Permalink: Appendix B. Reference Implementation\" href=\"#appendix-b-reference-implementation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 3 \uc5d0\uc11c \uc815\uc758\ud55c \uc138 \uc9c0\ud45c\ub294 \uac01\uac01 \ud568\uc218 \ud558\ub098\ub85c \uc62e\uaca8\uc9c4\ub2e4. <code>r2_oos<\/code> \uac00 3.1 \uc758 <code>R2_oos<\/code> \ub97c, <code>r2_frd<\/code>\n\uac00 3.2 \uc758 <code>R2_frd<\/code> \ub97c, <code>r2_base<\/code> \uac00 3.3 \uc758 <code>R2_base<\/code> \ub97c \ub9e1\ub294\ub2e4.<\/p>\n<p dir=\"auto\">\uc14b \ubaa8\ub450 \uad00\uce21\uac12 <code>y_true<\/code> \uc640 \uc608\uce21\uac12 <code>y_pred<\/code> \ub97c \ubc1b\uc544 skill \uac12 \ud558\ub098\ub97c \ub3cc\ub824\uc8fc\uba70, \ub2e4\ub978 \uacf3\uc740 \ubd84\ubaa8\uac00 \uc5b4\ub514\uc11c\n\uc624\ub294\uac00 \ud55c \uad70\ub370\ubfd0\uc774\ub2e4. <code>r2_oos<\/code> \ub294 \ud559\uc2b5 \ud3c9\uade0 <code>y_train_bar<\/code> \ub97c, <code>r2_frd<\/code> \ub294 \uae30\uc900 \uc0b0\ud3ec <code>sigma_ref<\/code> \ub97c,\n<code>r2_base<\/code> \ub294 baseline \uc608\uce21 vector <code>y_base<\/code> \ub97c \uac01\uac01 \uc778\uc790\ub85c \ubc1b\uc544 \uac70\uae30\uc11c \ubd84\ubaa8\ub97c \ub9cc\ub4e0\ub2e4. \uc14b \uac00\uc6b4\ub370\n\uc5b4\ub290 \uac83\ub3c4 \uae30\uc900\uc744 <code>y_true<\/code> \uc5d0\uc11c \ub04c\uc5b4\ub0b4\uc9c0 \uc54a\uace0 \ubaa8\ub450 \ubc14\uae65\uc5d0\uc11c \ubc1b\ub294\ub370, \uc774\uac83\uc774 section 2 \uac00 baseline \uc744\n\uba85\uc2dc\uc801\uc73c\ub85c \uace0\ub974\ub294 \uc77c\uc774\ub77c \ubd80\ub978 \uac83\uc744 code \ub85c \uc62e\uae34 \uac83\uc774\ub2e4. \ubd84\uc790 <code>SS_res<\/code> \ub294 \uc14b\uc774 \uac19\uc73c\ubbc0\ub85c <code>_ss_res<\/code> \ub85c\n\ube7c\ub0b4\uc5b4, \ubaa8\uc591 \uac80\uc0ac\uc640 \ube48 \ubc30\uc5f4 \uac80\uc0ac\ub97c \ud55c\uacf3\uc5d0 \ub454\ub2e4.<\/p>\n<p dir=\"auto\"><code>r2_base<\/code> \ub97c \uba3c\uc800 \uc815\uc758\ud558\uace0 <code>r2_oos<\/code> \uac00 \uadf8\uac83\uc744 \ubd80\ub974\uac8c \ud55c \uac83\uc740 section 3.3 \uc758 \ub9c8\uc9c0\ub9c9 \ubb38\ub2e8\uc744 code \ub85c\n\uc62e\uae34 \uac83\uc774\ub2e4. \ubc18\uba74 <code>r2_frd<\/code> \uc758 \ubd84\ubaa8\ub294 \uc5b4\ub5a4 \uc608\uce21 vector \uc758 \uc794\ucc28\ub3c4 \uc544\ub2c8\uc5b4\uc11c <code>r2_base<\/code> \ub97c \ud1b5\ud574 \ud45c\ud604\ud560 \uc218\n\uc5c6\uc73c\ubbc0\ub85c \ub530\ub85c \uacc4\uc0b0\ud55c\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nimport numpy as np\n\n\ndef _ss_res(y_true: np.ndarray = None, y_pred: np.ndarray = None) -&gt; float:\n    &quot;&quot;&quot;Residual sum of squares, shared by the numerator and by baseline denominators.&quot;&quot;&quot;\n    if y_true.shape != y_pred.shape:\n        raise ValueError(f&quot;shapes must match, got y_true {y_true.shape} and y_pred {y_pred.shape}.&quot;)\n    if y_true.size == 0:\n        raise ValueError(&quot;y_true is empty; a skill score needs at least one observation.&quot;)\n\n    return float(np.sum((y_true - y_pred) ** 2))\n\n\ndef r2_base(y_true: np.ndarray = None, y_pred: np.ndarray = None, y_base: np.ndarray = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.3 \u2014 skill against a baseline that answers per sample.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        y_base: baseline predictions, shape (n,), one value per sample.\n\n    Returns:\n        The skill relative to y_base. Negative when the baseline is the better predictor.\n    &quot;&quot;&quot;\n    ss_base = _ss_res(y_true=y_true, y_pred=y_base)\n    if ss_base == 0.0:\n        raise ValueError(&quot;the baseline reproduces y_true exactly, so there is no error to improve on.&quot;)\n\n    return 1.0 - _ss_res(y_true=y_true, y_pred=y_pred) \/ ss_base\n\n\ndef r2_oos(y_true: np.ndarray = None, y_pred: np.ndarray = None, y_train_bar: float = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.1 \u2014 skill against the mean that was known at training time.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        y_train_bar: mean of the training targets. Never derived from y_true, which would\n            put the test mean into the baseline and leak the evaluation set.\n\n    Returns:\n        The skill relative to always predicting y_train_bar.\n    &quot;&quot;&quot;\n    if y_train_bar is None:\n        raise ValueError(&quot;y_train_bar is required; taking the mean of y_true would leak the test set.&quot;)\n\n    y_base = np.full(shape=y_true.shape, fill_value=float(y_train_bar))\n    return r2_base(y_true=y_true, y_pred=y_pred, y_base=y_base)\n\n\ndef r2_frd(y_true: np.ndarray = None, y_pred: np.ndarray = None, sigma_ref: float = None) -&gt; float:\n    &quot;&quot;&quot;Section 3.2 \u2014 skill against a fixed reference dispersion instead of the data spread.\n\n    Args:\n        y_true: observations, shape (n,).\n        y_pred: predictions, shape (n,).\n        sigma_ref: reference dispersion in the unit of y, strictly positive.\n\n    Returns:\n        The skill relative to a baseline whose error scale is sigma_ref.\n        Equal to 1 - (RMSE \/ sigma_ref) ** 2.\n    &quot;&quot;&quot;\n    if sigma_ref is None or sigma_ref &lt;= 0.0:\n        raise ValueError(f&quot;sigma_ref must be a positive dispersion, got {sigma_ref}.&quot;)\n\n    # The denominator is a stated error scale, not the residual of any prediction vector,\n    # so it cannot be routed through r2_base.\n    ss_ref = float(y_true.size) * sigma_ref ** 2\n    return 1.0 - _ss_res(y_true=y_true, y_pred=y_pred) \/ ss_ref\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">numpy<\/span> <span class=\"pl-k\">as<\/span> <span class=\"pl-s1\">np<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Residual sum of squares, shared by the numerator and by baseline denominators.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span> <span class=\"pl-c1\">!=<\/span> <span class=\"pl-s1\">y_pred<\/span>.<span class=\"pl-c1\">shape<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"shapes must match, got y_true <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span><span class=\"pl-kos\">}<\/span><\/span> and y_pred <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">y_pred<\/span>.<span class=\"pl-c1\">shape<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">size<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"y_true is empty; a skill score needs at least one observation.\"<\/span>)\n\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">sum<\/span>((<span class=\"pl-s1\">y_true<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>))\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_base<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_base<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.3 \u2014 skill against a baseline that answers per sample.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        y_base: baseline predictions, shape (n,), one value per sample.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to y_base. Negative when the baseline is the better predictor.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-s1\">ss_base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_base<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">ss_base<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0.0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"the baseline reproduces y_true exactly, so there is no error to improve on.\"<\/span>)\n\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">ss_base<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_oos<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_train_bar<\/span>: <span class=\"pl-smi\">float<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.1 \u2014 skill against the mean that was known at training time.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        y_train_bar: mean of the training targets. Never derived from y_true, which would<\/span>\n<span class=\"pl-s\">            put the test mean into the baseline and leak the evaluation set.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to always predicting y_train_bar.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">y_train_bar<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">\"y_train_bar is required; taking the mean of y_true would leak the test set.\"<\/span>)\n\n    <span class=\"pl-s1\">y_base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">full<\/span>(<span class=\"pl-s1\">shape<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">shape<\/span>, <span class=\"pl-s1\">fill_value<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">y_train_bar<\/span>))\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">r2_base<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>, <span class=\"pl-s1\">y_base<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_base<\/span>)\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">r2_frd<\/span>(<span class=\"pl-s1\">y_true<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">y_pred<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">sigma_ref<\/span>: <span class=\"pl-smi\">float<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Section 3.2 \u2014 skill against a fixed reference dispersion instead of the data spread.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        y_true: observations, shape (n,).<\/span>\n<span class=\"pl-s\">        y_pred: predictions, shape (n,).<\/span>\n<span class=\"pl-s\">        sigma_ref: reference dispersion in the unit of y, strictly positive.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The skill relative to a baseline whose error scale is sigma_ref.<\/span>\n<span class=\"pl-s\">        Equal to 1 - (RMSE \/ sigma_ref) ** 2.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span> <span class=\"pl-c1\">or<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">&lt;=<\/span> <span class=\"pl-c1\">0.0<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"sigma_ref must be a positive dispersion, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">sigma_ref<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n\n    <span class=\"pl-c\"># The denominator is a stated error scale, not the residual of any prediction vector,<\/span>\n    <span class=\"pl-c\"># so it cannot be routed through r2_base.<\/span>\n    <span class=\"pl-s1\">ss_ref<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">y_true<\/span>.<span class=\"pl-c1\">size<\/span>) <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">sigma_ref<\/span> <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">_ss_res<\/span>(<span class=\"pl-s1\">y_true<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_true<\/span>, <span class=\"pl-s1\">y_pred<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">y_pred<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">ss_ref<\/span><\/pre><\/div>\n<\/article><\/div><\/div><\/p>\n<\/div><\/div>\n<\/div><\/div><\/div>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>\ud83c\uddfa\ud83c\uddf8\ud83c\uddf0\ud83c\uddf7 R\u00b2&#8217;s denominator is the error of a baseline, and standard R\u00b2 fixes that baseline to the dataset mean \u2014 which is why one model scores 0.94 on one lot and 0.31 on another at identical RMSE. Swap in a training mean, spec tolerance, or incumbent model, and the metric compares across lots.<\/p>\n","protected":false},"author":4,"featured_media":6793,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","fifu_image_url":"","fifu_image_alt":"","iawp_total_views":17,"footnotes":""},"categories":[321,56,369,431],"tags":[386,388],"class_list":["post-6792","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-math-slug","category-data-science-slug","category-evalutaion-metric-slug","category-regression-slug","tag-github-hosted","tag-r2"],"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":2,"sum_votes":9},"jetpack_featured_media_url":"https:\/\/ykim.synology.me\/wordpress\/wp-content\/uploads\/2026\/08\/georgetown-resort-pool-ledge-loungers.jpg","_links":{"self":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/comments?post=6792"}],"version-history":[{"count":6,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6792\/revisions"}],"predecessor-version":[{"id":7460,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6792\/revisions\/7460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media\/6793"}],"wp:attachment":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media?parent=6792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/categories?post=6792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/tags?post=6792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}