<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abheet</title>
    <description>The latest articles on DEV Community by Abheet (@abheetsharma09).</description>
    <link>https://dev.to/abheetsharma09</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4208227%2Fdc0e59a6-6fcb-4b50-b96a-d71373d760e0.jpg</url>
      <title>DEV Community: Abheet</title>
      <link>https://dev.to/abheetsharma09</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abheetsharma09"/>
    <language>en</language>
    <item>
      <title>Does log-transforming the target improve a linear regression model? A small comparison</title>
      <dc:creator>Abheet</dc:creator>
      <pubDate>Fri, 06 Nov 2026 15:26:41 +0000</pubDate>
      <link>https://dev.to/abheetsharma09/does-log-transforming-the-target-improve-a-linear-regression-model-a-small-comparison-2mn4</link>
      <guid>https://dev.to/abheetsharma09/does-log-transforming-the-target-improve-a-linear-regression-model-a-small-comparison-2mn4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hypothesis&lt;/strong&gt; :- If a dataset has a few very large target values(skewed dataset), taking the log of the target should help a linear regression predict better, because those few big values will no longer dominate the fit. If the target is already balanced, I expect no real difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a skewed target??
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkkr8kffvv5dejxkqxyce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkkr8kffvv5dejxkqxyce.png" alt="Medical Insurance Dataset Target Histplot" width="800" height="315"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 1: Histogram illustrating the right-skewed distribution of the target variable (medical insurance charges) across the dataset.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lets talk about right-skewed target the left skewed idea is also the same. A target is right-skewed when most values are small and a few are very large, so the histogram has a long tail on the right. Insurance charges are an example: most people pay a few thousand, but a few pay much more. In the above pair of images you can see how a right-skewed graph is now became a close to normally distributed graph after the log transformation &lt;code&gt;ln(1+𝑥)&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Definition of &lt;em&gt;“better”&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;As we get lower MAE , RMSE and higher R² score this could be a better model and can be our goal. This generally indicate higher prediction accuracy and smaller errors. Error is measured on unseen data &lt;strong&gt;&lt;em&gt;(Error is measured on 20 random [80/20] train/test splits)&lt;/em&gt;&lt;/strong&gt; and on the original, untransformed target, so that all models are compared in the same units.&lt;/p&gt;
&lt;h2&gt;
  
  
  Mathematical Formulation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Model A (raw target):&lt;/strong&gt;  

&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;y&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;β&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;β&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;⋯&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;β&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model B (log target):&lt;/strong&gt;  
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;lo&lt;span&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;y&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;⋯&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;′&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;y&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;exp&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord accent"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;γ&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="accent-body"&gt;&lt;span class="mord"&gt;^&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;…&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="delimsizing size1"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/p&gt;

&lt;p&gt;I used γ for B’s weights because they’re different numbers from A’s, and the hat on ŷ means “the model’s prediction.” The second part is your &lt;code&gt;np.expm1()&lt;/code&gt; step, and it shows that predictions were converted back to the original scale.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;x₁ to x_p are input columns (age, BMI, and so on).&lt;/li&gt;
&lt;li&gt;ε is the leftover error the line can’t explain.&lt;/li&gt;
&lt;li&gt;The betas are just the weights the model learns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;For the experiment conducted i used LinerRegression class of skLearn&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Universal Preprocessing before Prediction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For Model B&lt;/strong&gt;: I added a safeguard that clips/clamps the log predictions(execute after the model predicts its values) to the absolute minimum and maximum log charges present in the training data respectively: &lt;code&gt;np.clip(pred_b_log, min_log_val, max_log_val)&lt;/code&gt;. This prevents exponential reconstruction explosions(too much higher values) when executing &lt;code&gt;np.expm1()&lt;/code&gt; on the predictions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Model A&lt;/strong&gt;: Raw predictions are clamped to the minimum and maximum raw target values seen in the training data respectively: &lt;code&gt;[y_train.min(), y_train.max()]&lt;/code&gt; AS &lt;code&gt;np.clip(pred_a_raw, min_raw_val, max_raw_val)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Medical Insurance Costs Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name and Source&lt;/strong&gt; :- &lt;a href="https://www.kaggle.com/datasets/rahulvyasm/medical-insurance-cost-prediction" rel="noopener noreferrer"&gt;Medical Insurance Cost Prediction, Kaggle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- The dataset comprises 1338 rows (after dropping the duplicate values) and 7 columns, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;Age&lt;/code&gt;: Primary beneficiary's age (18 to 64)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Sex&lt;/code&gt;: Gender of the beneficiary (male / female)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;BMI&lt;/code&gt;: Body mass index (weight in kg / height in meters squared) &lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Children&lt;/code&gt;: Number of children / dependents covered &lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Smoker&lt;/code&gt;: Smoking status (yes / no) &lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Region&lt;/code&gt;: Residential area in the US (southwest, southeast, northwest, northeast)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Charges&lt;/code&gt;: Individual medical costs billed by health insurance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, &lt;code&gt;Charges&lt;/code&gt; is the target/output column, and rest is the input columns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Treatment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Age&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BMI&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Children&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sex&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoker&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Region&lt;/td&gt;
&lt;td&gt;categorical (4 values)&lt;/td&gt;
&lt;td&gt;one-hot encoded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charges&lt;/td&gt;
&lt;td&gt;target/numeric&lt;/td&gt;
&lt;td&gt;Model A: raw. Model B: &lt;code&gt;log1p&lt;/code&gt;, then &lt;code&gt;expm1&lt;/code&gt; on predictions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Additional preprocessing
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Duplicate Removal&lt;/strong&gt;: We dropped duplicate entries (&lt;code&gt;.drop_duplicates()&lt;/code&gt;) to prevent identical rows from appearing in both train and test splits.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Logical Boundary Validation&lt;/strong&gt;: We filtered out logically impossible values, specifically ensuring &lt;code&gt;age &amp;gt; 0&lt;/code&gt; and &lt;code&gt;charges &amp;gt; 0&lt;/code&gt; (in target column). This removes corrupt placeholder data before it reaches the model.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Medical Insurance Costs: results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0–19). Both models are scored on the original (untransformed) target. \&lt;br&gt;
&lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;1.51&lt;/code&gt; before the log, &lt;code&gt;-0.09&lt;/code&gt; after.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.741 ± 0.032&lt;/td&gt;
&lt;td&gt;6,066 ± 465&lt;/td&gt;
&lt;td&gt;4,204 ± 261&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.533 ± 0.071&lt;/td&gt;
&lt;td&gt;8,117 ± 587&lt;/td&gt;
&lt;td&gt;4,182 ± 391&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding:&lt;/strong&gt; On this dataset, my hypothesis was not supported. Log-transforming the target made predictions worse on the original scale for R² and RMSE. MAE was slightly lower for the log model, but the gap was small compared with the variation across splits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/med-insurance_predictions.csv" rel="noopener noreferrer"&gt;/results/med-insurance_predictions.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Diamonds Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name &amp;amp; Source&lt;/strong&gt; :- &lt;a href="https://github.com/mwaskom/seaborn-data/blob/master/diamonds.csv" rel="noopener noreferrer"&gt;Diamonds Dataset, Seaborn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- The Seaborn diamonds dataset contains 53,940 rows and 10 columns detailing the prices and physical attributes of round-cut diamonds.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;price&lt;/code&gt;: Price in US dollars ($326 to $18,823)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;carat&lt;/code&gt;: Weight of the diamond (0.2 to 5.01)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;cut&lt;/code&gt;: Quality of the cut (&lt;em&gt;Fair, Good, Very Good, Premium, Ideal&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;color&lt;/code&gt;: Diamond color, from &lt;em&gt;J&lt;/em&gt; (worst) to &lt;em&gt;D&lt;/em&gt; (best)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;clarity&lt;/code&gt;: Measurement of clarity (&lt;em&gt;I1&lt;/em&gt; [worst] to &lt;em&gt;IF&lt;/em&gt; [best])&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;depth&lt;/code&gt;: Total depth percentage (&lt;code&gt;2 * z / (x + y)&lt;/code&gt;), ranging from 43% to 79%&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;table&lt;/code&gt;: Width of the top of the diamond relative to widest point (43 to 95)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;z&lt;/code&gt;: Length, width, and depth in mm&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Target Variable Distribution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01brpwzsoigk4997a4wh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F01brpwzsoigk4997a4wh.png" alt="Diamond Dataset Target Histplot" width="799" height="311"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 2: Histogram illustrating the right-skewed distribution of the target variable (diamond datset prices) across the dataset.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Treatment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;carat&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;depth&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;table&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;x&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;y&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;z&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cut&lt;/td&gt;
&lt;td&gt;categorical (ordinal - 5 values)&lt;/td&gt;
&lt;td&gt;mapped to sequential integers (Fair=0 to Ideal=4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;color&lt;/td&gt;
&lt;td&gt;categorical (ordinal - 7 values)&lt;/td&gt;
&lt;td&gt;mapped to sequential integers (J=0 to D=6)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clarity&lt;/td&gt;
&lt;td&gt;categorical (ordinal - 8 values)&lt;/td&gt;
&lt;td&gt;mapped to sequential integers (I1=0 to IF=7)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;price&lt;/td&gt;
&lt;td&gt;target/numeric&lt;/td&gt;
&lt;td&gt;Model A: raw. Model B: &lt;code&gt;log1p&lt;/code&gt;, then &lt;code&gt;expm1&lt;/code&gt; on predictions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Additional Preprocessing
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Data Cleaning (Before training the model ,Removing Typos):&lt;/strong&gt; I removed the physical impossibility records (where dimensions &lt;code&gt;y&lt;/code&gt; or &lt;code&gt;z&lt;/code&gt; are larger than 20mm for small diamonds). This is standard practice in data science because keeping obvious typos in your test set corrupts performance evaluations.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Diamonds Dataset : results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0-19). Both models are scored on the original (untransformed) target. \&lt;br&gt;
&lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;1.62&lt;/code&gt; before the log, &lt;code&gt;0.12&lt;/code&gt; after.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.921 ± 0.002&lt;/td&gt;
&lt;td&gt;1,114 ± 16&lt;/td&gt;
&lt;td&gt;715 ± 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.953 ± 0.001&lt;/td&gt;
&lt;td&gt;859 ± 13&lt;/td&gt;
&lt;td&gt;456 ± 4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding&lt;/strong&gt;: Model B's is perfroming better on every metric especially MAE and slightly better on R² ,RMSE now the Model B here is performing quit well. So, here on this current dataset and setup i can say result is consistent with my hypothesis by a small margin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/diamondDS_predictions_robust.csv" rel="noopener noreferrer"&gt;/results/diamondDS_predictions_robust.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  California Housing Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name &amp;amp; Source&lt;/strong&gt; :- &lt;a href="https://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_california_housing.html" rel="noopener noreferrer"&gt;fetch_california_housing from Scikit-Learn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- This datasets contains 20,640rows and 9columns(8 input and 1 target) derived from the 1990 U.S. Census for California.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;MedInc&lt;/code&gt;: Median income in the block group&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;HouseAge&lt;/code&gt;: Median house age in the block group&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;AveRooms&lt;/code&gt;: Average number of rooms per household&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;AveBedrms&lt;/code&gt;: Average number of bedrooms per household&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Population&lt;/code&gt;: Block group population&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;AveOccup&lt;/code&gt;: Average house occupancy (number of household members)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Latitude&lt;/code&gt;: House block latitude&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Longitude&lt;/code&gt;: House block longitude&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;MedHouseVal&lt;/code&gt;: Median house value for California districts, expressed in hundreds of thousands of dollars ($100,000) (target/ output column)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Target Variable Distribution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxwcq4tavk076ji1lmdko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxwcq4tavk076ji1lmdko.png" alt="Diamond Dataset Target Histplot" width="799" height="313"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 3: Histogram illustrating the medium right skeweness of the target variable (california housing dataset) and a extreame outlier&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;p&gt;Here, for this dataset their is no need for any preprocessing. Dropped duplicates just as a standard sanity check and applied clips/claps to bothe Model A &amp;amp; Model B.&lt;/p&gt;

&lt;h3&gt;
  
  
  California Housing Dataset : results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0-19). Both models are scored on the original (untransformed) target. \&lt;br&gt;
&lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;0.98&lt;/code&gt; before the log, &lt;code&gt;0.28&lt;/code&gt; after. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.618 ± 0.008&lt;/td&gt;
&lt;td&gt;0.713 ± 0.008&lt;/td&gt;
&lt;td&gt;0.522 ± 0.005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.615 ± 0.008&lt;/td&gt;
&lt;td&gt;0.716 ± 0.010&lt;/td&gt;
&lt;td&gt;0.497 ± 0.006&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding:&lt;/strong&gt; On this dataset both the models were close. Model A was slightly ahead on R² and RMSE, but the gaps were smaller than the variation across splits, so I treat them as tied. Model B had a clearly lower MAE (0.497 vs 0.522). The target has moderate skew (0.98), so this dataset does not clearly test either side of the hypothesis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/calif-housingDS_predictions_robust.csv" rel="noopener noreferrer"&gt;results/calif-housingDS_predictions_robust.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Airfoil Self-Noise Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name &amp;amp; Source&lt;/strong&gt; :- &lt;a href="https://archive.ics.uci.edu/dataset/291/airfoil+self+noise" rel="noopener noreferrer"&gt;Airfoil Self-Noise Dataset, UCI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- It has 1,503 rows and 6 attributes/columns (5 input features, 1 target variable) derived from NASA wind tunnel tests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Frequency&lt;/code&gt;: f (in Hertz, Hz)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Angle of Attack&lt;/code&gt;: α (in degrees, °)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Chord Length&lt;/code&gt;: c (in meters, m)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Free-stream Velocity&lt;/code&gt;: in meters per second, m/s&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Suction Side Displacement Thickness&lt;/code&gt;: δ (in meters, m)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Scaled Sound Pressure Level&lt;/code&gt;: SPL (in decibels, dB) (Output / Target Column)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Target Variable Distribution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa4hv6gkul6382h40qgz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa4hv6gkul6382h40qgz2.png" alt="Airfoil Self-Noise Dataset Target Histplot" width="799" height="313"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 4: Histogram illustrating that the target here isn’t right-skewed. It’s mildly left-skewed &lt;code&gt;−0.41&lt;/code&gt;, and the log made it slightly more skewed &lt;code&gt;−0.54&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;p&gt;Here, for this dataset their is no need for any preprocessing as all the columns are numerical. Dropped duplicates just as a standard sanity check[but no duplicate found] and applied clips/claps to both Model A &amp;amp; Model B.&lt;/p&gt;

&lt;h3&gt;
  
  
  Airfoil Self-Noise Dataset : results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0-19). Both models are scored on the original (untransformed) target. &lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;-0.41&lt;/code&gt; before the log, &lt;code&gt;-0.54&lt;/code&gt; after.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.497 ± 0.043&lt;/td&gt;
&lt;td&gt;4.837 ± 0.248&lt;/td&gt;
&lt;td&gt;3.746 ± 0.166&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.488 ± 0.044&lt;/td&gt;
&lt;td&gt;4.877 ± 0.247&lt;/td&gt;
&lt;td&gt;3.769 ± 0.165&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding&lt;/strong&gt;: On this dataset both the models were close. Model A was slightly ahead on each parameter, but the gaps were far smaller. The results are consistent with the second half of the hypothesis(If the target is already balanced, I expect no real difference).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/airfoilDS_predictions_robust.csv" rel="noopener noreferrer"&gt;results/airfoilDS_predictions_robust.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Concrete Compressive Strength Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name &amp;amp; Source&lt;/strong&gt; :- &lt;a href="https://archive.ics.uci.edu/dataset/165/concrete+compressive+strength" rel="noopener noreferrer"&gt;Concrete Compressive Strength, UCI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- It has 1030 rows and 9 attributes/columns (8 input features, 1 target variable).&lt;/p&gt;

&lt;h3&gt;
  
  
  Features Units &amp;amp; Details
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column Name (In Dataset)&lt;/th&gt;
&lt;th&gt;Variable Description&lt;/th&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;Measurement Unit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;cement&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cement component quantity in the mix&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;slag&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Blast furnace slag component quantity&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ash&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fly ash component quantity in the mix&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;water&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Water component quantity in the mix&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;superplastic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Superplasticizer additive quantity&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;coarseagg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Coarse aggregate component quantity&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;fineagg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fine aggregate component quantity&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{kg/m}^3$&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;age&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Age of the concrete before testing&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;Days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;strength&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;[Target Variable]&lt;/strong&gt; Measured compressive strength&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;$\text{MPa}$&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Target Variable Distribution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F00eyi1oew8rn8qbdlr0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F00eyi1oew8rn8qbdlr0r.png" alt="Concrete Compressive Strength Dataset Target Histplot" width="800" height="314"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 5: Histogram illustrating the little right skeweness of the target variable (concrete compressive strength dataset) but after applying log it shows a left skewed graph.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;p&gt;Here, for this dataset their is no need for any preprocessing as all the columns are flaot/numerical. Dropped duplicates just as a standard sanity check[25 duplicated found] and applied clips/claps to both Model A &amp;amp; Model B.&lt;/p&gt;

&lt;h3&gt;
  
  
  Concrete Compressive Strength Dataset : results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0-19). Both models are scored on the original (untransformed) target. &lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;0.40&lt;/code&gt; before the log, &lt;code&gt;-0.81&lt;/code&gt; after.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.598 ± 0.035&lt;/td&gt;
&lt;td&gt;10.225 ± 0.430&lt;/td&gt;
&lt;td&gt;8.124 ± 0.338&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.495 ± 0.052&lt;/td&gt;
&lt;td&gt;11.459 ± 0.563&lt;/td&gt;
&lt;td&gt;9.031 ± 0.419&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding&lt;/strong&gt;: Here, clearly Model A is performing better than B in every metric. We applied log despite the target is already close to normal. So, here in this case the log is not contributing rather it is make things even worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/concrete_strength_predictions_robust.csv" rel="noopener noreferrer"&gt;results/concrete_strength_predictions_robust.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Housing Prices Dataset
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Name &amp;amp; Source&lt;/strong&gt; :- &lt;a href="https://www.kaggle.com/datasets/yasserh/housing-prices-dataset" rel="noopener noreferrer"&gt;Housing Prices Dataset, Kaggle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Details&lt;/strong&gt; :- It contains 545 samples with 13 features(12 INPUT + 1 TARGET COLUMN).&lt;/p&gt;

&lt;h3&gt;
  
  
  Features Units &amp;amp; Details
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column Name&lt;/th&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;price&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Float&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;The Target Variable.&lt;/strong&gt; The final sale price of the house.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;area&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Float&lt;/td&gt;
&lt;td&gt;Total plot or floor area of the house (typically in square feet).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;bedrooms&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Int&lt;/td&gt;
&lt;td&gt;Total number of bedrooms (1 to 6+).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;bathrooms&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Int&lt;/td&gt;
&lt;td&gt;Total number of bathrooms.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;stories&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Int&lt;/td&gt;
&lt;td&gt;Number of levels/floors the house has (e.g., 1, 2, 3, 4).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;mainroad&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Is the house connected/facing a main road? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;guestroom&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Does the house have a dedicated guest room? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;basement&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Does the house have a basement? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;hotwaterheating&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Does the house feature hot water central heating? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;airconditioning&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Does the house have an A/C system installed? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;parking&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Int&lt;/td&gt;
&lt;td&gt;Number of dedicated car parking spaces available (0 to 3).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;prefarea&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Binary)&lt;/td&gt;
&lt;td&gt;Is the house located in a preferred/premium neighborhood? (yes / no).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;furnishingstatus&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Categorical (Nominal)&lt;/td&gt;
&lt;td&gt;The interior status: furnished, semi-furnished, or unfurnished.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Target Variable Distribution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0t0yu3ro2t4ggj1yvvcf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0t0yu3ro2t4ggj1yvvcf.png" alt="Housing Prices Dataset Target Histplot" width="800" height="314"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 6: Histogram illustrating the right skeweness of the target variable (housing prices dataset) but after applying log it gets close to normally distributed.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Preprocessing (identical for both models):-
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Treatment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;area&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bedrooms&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bathrooms&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;stories&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;parking&lt;/td&gt;
&lt;td&gt;numeric&lt;/td&gt;
&lt;td&gt;no changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mainroad&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;guestroom&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;basement&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;hotwaterheating&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;airconditioning&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;prefarea&lt;/td&gt;
&lt;td&gt;categorical (2 values)&lt;/td&gt;
&lt;td&gt;encoded as 0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;furnishingstatus&lt;/td&gt;
&lt;td&gt;categorical (3 values)&lt;/td&gt;
&lt;td&gt;one-hot encoded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;price&lt;/td&gt;
&lt;td&gt;target/numeric&lt;/td&gt;
&lt;td&gt;Model A: raw. Model B: &lt;code&gt;log1p&lt;/code&gt;, then &lt;code&gt;expm1&lt;/code&gt; on predictions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Housing Dataset : results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt; 20 random 80/20 train/test splits (seeds 0-19). Both models are scored on the original (untransformed) target. &lt;strong&gt;Target skewness:&lt;/strong&gt; &lt;code&gt;1.17&lt;/code&gt; before the log, &lt;code&gt;0.13&lt;/code&gt; after.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;R² (mean ± std)&lt;/th&gt;
&lt;th&gt;RMSE (mean ± std)&lt;/th&gt;
&lt;th&gt;MAE (mean ± std)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A: raw target&lt;/td&gt;
&lt;td&gt;0.652 ± 0.037&lt;/td&gt;
&lt;td&gt;1,089,414 ± 119,685&lt;/td&gt;
&lt;td&gt;798,663 ± 67,657&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B: log target&lt;/td&gt;
&lt;td&gt;0.665 ± 0.054&lt;/td&gt;
&lt;td&gt;1,067,224 ± 126,055&lt;/td&gt;
&lt;td&gt;766,818 ± 74,769&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;± is the standard deviation across the 20 splits: how much the score typically changes from one split to another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding&lt;/strong&gt;: On this dataset both the models were close. Model B was slightly ahead on each parameter, but the gaps were too small. The results are consistent with the second half of the hypothesis(If the target is already balanced, I expect no real difference).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each Seeds results&lt;/strong&gt;: &lt;a href="https://raw.githubusercontent.com/abheetsharma09/ml-dl-from-scratch/refs/heads/main/Experiments/log_target_study/results/housing_predictions_robust.csv" rel="noopener noreferrer"&gt;results/housing_predictions_robust.csv&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary across all Datasets
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyg8wbkcdi2ie2zm8bbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyg8wbkcdi2ie2zm8bbb.png" alt="Paired Graph" width="800" height="317"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 7: Basic Grpah from the below table.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dataset&lt;/th&gt;
&lt;th&gt;Skewness (before → after log)&lt;/th&gt;
&lt;th&gt;Lower RMSE&lt;/th&gt;
&lt;th&gt;Lower MAE&lt;/th&gt;
&lt;th&gt;Better R² (higher)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Medical Insurance Costs&lt;/td&gt;
&lt;td&gt;1.51 → -0.09&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diamonds Dataset&lt;/td&gt;
&lt;td&gt;1.62 → 0.12&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;California Housing Dataset&lt;/td&gt;
&lt;td&gt;0.98 → 0.28&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Airfoil Self-Noise Dataset&lt;/td&gt;
&lt;td&gt;-0.41 → -0.54&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Concrete Compressive Strength Dataset&lt;/td&gt;
&lt;td&gt;0.40 → -0.81&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Housing Dataset&lt;/td&gt;
&lt;td&gt;1.17 → 0.13&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;em&gt;For RMSE and MAE, lower is better; for R², higher is better.&lt;/em&gt; \&lt;br&gt;
&lt;em&gt;**A&lt;/em&gt;&lt;em&gt;: raw target&lt;/em&gt; | &lt;em&gt;**B&lt;/em&gt;&lt;em&gt;: log target&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;According to the data analyzed across all datasets, we can draw the following key conclusions &lt;strong&gt;&lt;em&gt;[my hypothesis is correct but with few modifications]&lt;/em&gt;&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Skewness Rule of Thumb:&lt;/strong&gt; To obtain performance benefits from log-transforming targets in linear models, the target column &lt;strong&gt;must be significantly right-skewed&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Symmetrical Target Penalty:&lt;/strong&gt; If we apply a log transformation to a target that is already close to normal (or negatively skewed)—as observed with the &lt;strong&gt;Concrete Compressive Strength Dataset&lt;/strong&gt; (initial skew of &lt;code&gt;0.40&lt;/code&gt;)—model performance degrades significantly across R², RMSE, and MAE.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proportional Gains:&lt;/strong&gt; As the positive skewness of the target increases, the performance gains of Model B (Log) over Model A (Raw) grows[with exception like we encountered in Medical Insurance Dataset].&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpap98tinf6qnkprucdal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpap98tinf6qnkprucdal.png" alt="Multiple Graph" width="800" height="255"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 8: Multiple Graph here used to explain the Conclusion from the study.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Pattern (Graph 1 - Skewness vs. Error Reduction)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This regression plot highlights our operational rule of thumb: as the initial target skewness increases, the benefit of Model B (Log Target) increases.&lt;/li&gt;
&lt;li&gt;Highly skewed targets (like Diamonds at 1.62 and Housing at 1.17) show clear performance wins for Model B.&lt;/li&gt;
&lt;li&gt;Conversely, datasets with near-symmetric or negative initial skewness (such as Concrete Strength and Airfoil Self-Noise) are negatively impacted by the transformation, showing that Model A (Raw Target) is the superior configuration under those conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metric-by-Metric Performance Shift (Graph 2 - Heatmap)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The heatmap confirms that the performance shift is robust across all key evaluation metrics (R2, RMSE, and MAE).&lt;/li&gt;
&lt;li&gt;For instance, Diamonds experiences a 36.2% improvement in MAE and a 22.9% improvement in RMSE under the log transformation.&lt;/li&gt;
&lt;li&gt;Medical Insurance is an interesting exception: while it has high initial skewness (1.51), its R2 and RMSE degrade significantly under Model B. This indicates that while the log transform normalizes the distribution, the underlying relationship is highly linear[here features act as flat additions (e.g., a smoker fee adding a flat  $25,000  to base costs)] and is sensitive to exponential scaling back-transformation &lt;code&gt;np.expm1()&lt;/code&gt; errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Target Normalization Capability (Graph 3 - Skewness Shift)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This horizontal bar chart shows how effectively the log transformation centers the targets closer to 0 (perfect symmetry).&lt;/li&gt;
&lt;li&gt;We see massive normalizations for Diamonds (reduced from 1.62 to 0.12), Housing (reduced from 1.17 to 0.13), and Medical Insurance (reduced from 1.51 to -0.09).&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This repository contains work I have done that may or may not contain errors. Please verify the code and logic before replicating or using it.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>computerscience</category>
      <category>community</category>
    </item>
    <item>
      <title>🎬 YouTube Comment Analyser</title>
      <dc:creator>Abheet</dc:creator>
      <pubDate>Tue, 27 Oct 2026 14:47:48 +0000</pubDate>
      <link>https://dev.to/abheetsharma09/youtube-comment-analyser-4mmb</link>
      <guid>https://dev.to/abheetsharma09/youtube-comment-analyser-4mmb</guid>
      <description>&lt;p&gt;This is my personal mini-project — it takes any YouTube video URL, fetches all its comments, analyzes the sentiment, and gives you a clear verdict on whether the community loves it, hates it, or feels neutral about it.&lt;/p&gt;

&lt;p&gt;I built this to learn backend development with FastAPI, integrate with the YouTube Data API, and tackle real-world challenges like CORS while connecting a frontend to a backend.&lt;/p&gt;




&lt;p&gt;Visit the Github Repo Link :- &lt;a href="https://github.com/abheetsharma09/yt-comment-analyser" rel="noopener noreferrer"&gt;https://github.com/abheetsharma09/yt-comment-analyser&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sentiment Analysis&lt;/strong&gt; – Classifies comments as Positive, Neutral, or Negative.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Approval Rating&lt;/strong&gt; – Calculates the percentage of positive feedback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart Verdict&lt;/strong&gt; – Gives a clear verdict: "Must Watch 🌟", "Good 👍", "Mixed 🤔", or "Skip ⚠️".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sample Comments&lt;/strong&gt; – Shows top positive and negative comments for quick insights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three Interfaces&lt;/strong&gt; – Access the tool via CLI, Web UI, or REST API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beautiful Dashboard&lt;/strong&gt; – A glass‑morphism UI with real‑time feedback (for &lt;code&gt;/ui&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Video Metadata&lt;/strong&gt; – Displays video thumbnail and title alongside the report. (for &lt;code&gt;/ui&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚙️ How It Works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You provide a YouTube video URL&lt;/strong&gt; – through the CLI, web UI, or API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The backend extracts the video ID&lt;/strong&gt; and fetches all comments using the YouTube Data API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments are analyzed&lt;/strong&gt; using a simple rule‑based sentiment classifier (keywords + context).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A detailed report is generated&lt;/strong&gt; with:

&lt;ul&gt;
&lt;li&gt;Total reviews scanned&lt;/li&gt;
&lt;li&gt;Breakdown: Positive / Neutral / Negative&lt;/li&gt;
&lt;li&gt;Approval rating percentage&lt;/li&gt;
&lt;li&gt;Final verdict with explanation&lt;/li&gt;
&lt;li&gt;Sample positive &amp;amp; negative comments&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The report is returned&lt;/strong&gt; to the client (terminal, web dashboard, or JSON response).&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🚀 Versions
&lt;/h2&gt;

&lt;p&gt;I've provided &lt;strong&gt;three versions&lt;/strong&gt; of this tool to suit different use cases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CLI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/cli&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run from the terminal – perfect for quick analysis without a browser.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Web UI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/ui&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Beautiful interactive dashboard – paste a URL and see the report instantly.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;REST API endpoint – returns JSON data for integration with other apps.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;code&gt;NOTE - ALL REQUIRES API KEY EXCEPT MY DEPLOYED VERSION&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🧰 Tech Stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Backend&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;FastAPI (Python)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Frontend&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTML, CSS, JavaScript (Vanilla)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;External API&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;YouTube Data API v3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  📦 Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.8+&lt;/li&gt;
&lt;li&gt;A YouTube Data API v3 key (see API Key Setup)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Steps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clone the repository&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/yourusername/youtube-comment-analyser.git
&lt;span class="nb"&gt;cd &lt;/span&gt;youtube-comment-analyser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a virtual environment (recommended)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;span class="nb"&gt;source &lt;/span&gt;venv/bin/activate   &lt;span class="c"&gt;# On Windows: venv\Scripts\activate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install dependencies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fastapi uvicorn requests google-api-python-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set up environment variables&lt;/strong&gt;
Create a &lt;code&gt;.env&lt;/code&gt; file in the root directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;YOUTUBE_API_KEY=your_youtube_api_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run the application&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvicorn main:app &lt;span class="nt"&gt;--reload&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Open your browser&lt;/strong&gt; and navigate to:&lt;/li&gt;
&lt;li&gt;Web UI: &lt;code&gt;http://localhost:8000/ui&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;API: &lt;code&gt;http://localhost:8000/api/{video_id}&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🔑 API Key Setup
&lt;/h2&gt;

&lt;p&gt;To use the YouTube Data API, you'll need an API key:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the &lt;a href="https://console.cloud.google.com/" rel="noopener noreferrer"&gt;Google Cloud Console&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a new project (or select an existing one).&lt;/li&gt;
&lt;li&gt;Enable the &lt;strong&gt;YouTube Data API v3&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Create a credential (API Key) and copy it.&lt;/li&gt;
&lt;li&gt;Add it to your &lt;code&gt;.env&lt;/code&gt; file as &lt;code&gt;YOUTUBE_API_KEY&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Note&lt;/strong&gt;: The YouTube API has usage quotas. Free tier usually allows 10,000 requests per day, which is plenty for personal use.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  💻 Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CLI Version (&lt;code&gt;/cli&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Run the tool from your terminal for quick, no‑frills analysis.\&lt;br&gt;
HERE YOU HAVE TO PROVIDE &lt;code&gt;YOUR_API_KEY&lt;/code&gt; &amp;amp; &lt;code&gt;YT-VIDEO-ID&lt;/code&gt; to extract the following output.&lt;/p&gt;

&lt;p&gt;The output will look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;==================================================
🎬 VIDEO AUDIENCE REPORT FOR ID: UZio8TcTMrI
==================================================
📋 Total Reviews Scanned: 230
💬 Breakdown: 132 Pos | 91 Neu | 7 Neg
📈 Approval Rating: 95.0% Positive Feedback
🚨 FINAL VERDICT: MUST WATCH 🌟
📝 Summary: The community overwhelmingly praises this video.
==================================================


✨ KEY PRAISES (Why people like it):
  1. "very interesting lecture ,all the stuffs started making me more curious..."
  2. "Dada tumi khub valo porao . Thank you so much 😊😊"
  3. "most underrated channel ever 🔥"


🚩 CRITICAL POINTS (Viewer complaints):
  1. "bro hates BJP ...me too hahaha"
  2. "“I have a doubt: Can NLP detect sarcasm? ..."
  3. "why the language is not english?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Web UI Version (&lt;code&gt;/ui&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;The interactive dashboard — just paste a YouTube URL and get a beautiful, visual report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Access it via:&lt;/strong&gt; &lt;code&gt;http://localhost:8000/&lt;/code&gt; or you can simple open the &lt;code&gt;index.html&lt;/code&gt; in browser that also works fine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter a YouTube URL in the input box.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Analyze&lt;/strong&gt; (or press Enter).&lt;/li&gt;
&lt;li&gt;See the report instantly with stats, approval bar, verdict, and sample comments.&lt;/li&gt;
&lt;li&gt;Video thumbnail and title are fetched automatically.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Tip&lt;/strong&gt;: The UI works only with a valid API URL and you have to configure the CORS policies in your backend for testing i am using &lt;code&gt;NGINX&lt;/code&gt; and hosted UI on the Cloudflare CDN.&lt;br&gt;
YOU CAN CHANGE YOUR BASE API_URL IN &lt;code&gt;script.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;URL_HERE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  API Version (&lt;code&gt;/api&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;For developers who want to integrate the analysis into their own apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;GET /{video_id}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"http://localhost:8000/UZio8TcTMrI"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Response (JSON):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"video_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"UZio8TcTMrI"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"total_review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;230&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"vdo_breakdown"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"positive"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;132&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"neutral"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"negetive"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"percentage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"95.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"veridct"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MUST WATCH 🌟"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"quick_summary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The community overwhelmingly praises this video. High educational value."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"positive_comment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"very interesting lecture ,all the stuffs started making me more curious about learning ML"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"Dada tumi khub valo porao . Thank you so much 😊😊"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"most underrated channel ever 🔥"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"negative_comment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"bro hates BJP ...me too hahaha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"“I have a doubt: Can NLP detect sarcasm? ..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"why the language is not english?"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📚 What I Learned
&lt;/h2&gt;

&lt;p&gt;This project taught me &lt;strong&gt;a lot&lt;/strong&gt; about building full‑stack applications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;FastAPI Fundamentals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routing (&lt;code&gt;@app.get&lt;/code&gt;, &lt;code&gt;@app.post&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Path parameters and query parameters&lt;/li&gt;
&lt;li&gt;Middleware (including CORS middleware)&lt;/li&gt;
&lt;li&gt;Async/await for non‑blocking operations&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;YouTube Data API Integration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to authenticate and make requests&lt;/li&gt;
&lt;li&gt;Fetching comments (including pagination for large videos)&lt;/li&gt;
&lt;li&gt;Handling rate limits and quotas&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CORS (Cross‑Origin Resource Sharing)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why CORS errors happen (same‑origin policy)&lt;/li&gt;
&lt;li&gt;How to fix them using &lt;code&gt;CORSMiddleware&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The difference between &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt; preflight requests&lt;/li&gt;
&lt;li&gt;Handling &lt;code&gt;null&lt;/code&gt; origins for local development (&lt;code&gt;file://&lt;/code&gt; protocol)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Frontend Development&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch API with error handling&lt;/li&gt;
&lt;li&gt;Dynamically rendering reports with JavaScript&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;API Design&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a RESTful endpoint (&lt;code&gt;/{video_id}&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Returning consistent JSON responses&lt;/li&gt;
&lt;li&gt;Versioning through different routes (&lt;code&gt;/cli&lt;/code&gt;, &lt;code&gt;/ui&lt;/code&gt;, &lt;code&gt;/api&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem Solving&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debugging CORS errors with browser DevTools (Network tab)&lt;/li&gt;
&lt;li&gt;Handling API failures gracefully&lt;/li&gt;
&lt;li&gt;Testing API endpoints with &lt;code&gt;curl&lt;/code&gt; and Postman&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🔮 Future Improvements
&lt;/h2&gt;

&lt;p&gt;Here's what I'd like to add next:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI‑Powered Sentiment&lt;/strong&gt; – Use a pre‑trained NLP model (e.g., &lt;code&gt;transformers&lt;/code&gt;) for more accurate sentiment analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comment Filtering&lt;/strong&gt; – Skip spam or irrelevant comments for cleaner analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi‑Language Support&lt;/strong&gt; – Detect and analyze comments in any language.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt; – Cache results for 24 hours to reduce API calls and speed up repeated requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Video Insights&lt;/strong&gt; – Add data like view count, like/dislike ratio, and channel info.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export Reports&lt;/strong&gt; – Allow users to download reports as PDF or CSV.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User Authentication&lt;/strong&gt; – Add login to save analysis history.&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>backend</category>
      <category>github</category>
      <category>python</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
