<?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: Deepak Doriya</title>
    <description>The latest articles on DEV Community by Deepak Doriya (@unknown1803).</description>
    <link>https://dev.to/unknown1803</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%2F4013677%2Fc2390139-e642-4908-a6c0-d4468225c4cb.png</url>
      <title>DEV Community: Deepak Doriya</title>
      <link>https://dev.to/unknown1803</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unknown1803"/>
    <language>en</language>
    <item>
      <title>Beyond the Basics: What I learned from a Deep-Dive EDA on the Ames Housing Dataset</title>
      <dc:creator>Deepak Doriya</dc:creator>
      <pubDate>Mon, 24 Aug 2026 05:00:26 +0000</pubDate>
      <link>https://dev.to/unknown1803/beyond-the-basics-what-i-learned-from-a-deep-dive-eda-on-the-ames-housing-dataset-20c4</link>
      <guid>https://dev.to/unknown1803/beyond-the-basics-what-i-learned-from-a-deep-dive-eda-on-the-ames-housing-dataset-20c4</guid>
      <description>&lt;p&gt;Hey everyone! As I’m working through my ML fundamentals, I wanted to share a deep-dive Exploratory Data Analysis (EDA) I just completed on the classic Ames, Iowa Housing Dataset. &lt;/p&gt;

&lt;p&gt;If you are unfamiliar, the Ames dataset is basically the "final boss" version of the Boston Housing dataset. It has 2,930 residential properties and 80+ explanatory variables.&lt;/p&gt;

&lt;p&gt;Instead of just running a standard &lt;code&gt;df.describe()&lt;/code&gt;, I wanted to focus on &lt;strong&gt;Feature Engineering&lt;/strong&gt; and &lt;strong&gt;understanding the actual business logic&lt;/strong&gt; behind the data. Here are my biggest takeaways and a few counter-intuitive findings!&lt;/p&gt;




&lt;h3&gt;
  
  
  🛠️ 1. Smarter Feature Engineering
&lt;/h3&gt;

&lt;p&gt;When I first looked at the data, the square footage was split across multiple columns (basement, 1st floor, 2nd floor). Instead of feeding the model raw variables, I created a few composite features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Total_Usable_SF&lt;/code&gt;&lt;/strong&gt;: I combined Above-Grade Living Area and Total Basement square footage. This gave a much more realistic picture of the home's total usable space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Price_Per_SqFt&lt;/code&gt;&lt;/strong&gt;: By dividing the Sale Price by my new &lt;code&gt;Total_Usable_SF&lt;/code&gt;, I created a normalized metric. This made comparing different neighborhoods &lt;em&gt;way&lt;/em&gt; easier, removing the bias of house size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log Transformation&lt;/strong&gt;: The &lt;code&gt;Sale_Price&lt;/code&gt; was heavily right-skewed (a few multi-million dollar mansions were dragging the tail). Applying a logarithmic transformation (&lt;code&gt;np.log1p&lt;/code&gt;) instantly normalized the distribution, which is crucial for linear modeling assumptions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Normalizing the target variable
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Log_Sale_Price&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log1p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Sale_Price&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;histplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Log_Sale_Price&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;kde&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📊 2. The Power of "Missing" Data
&lt;/h3&gt;

&lt;p&gt;Usually, missing data is annoying. But in housing, "NaN" rarely means the data is missing—it usually means the house structurally &lt;em&gt;lacks&lt;/em&gt; that feature.&lt;/p&gt;

&lt;p&gt;I converted missing values for things like Pools, Fences, and Garages into &lt;strong&gt;binary presence/absence flags&lt;/strong&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lacking a &lt;strong&gt;Basement&lt;/strong&gt; or &lt;strong&gt;Garage&lt;/strong&gt; carried a massive median price penalty of &lt;strong&gt;65% to 85%+&lt;/strong&gt;. In a climate like Iowa, homes without these are almost exclusively low-end starter tiers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤯 3. Counter-Intuitive Correlations
&lt;/h3&gt;

&lt;p&gt;This was my favorite part of the analysis. Sometimes, features that &lt;em&gt;sound&lt;/em&gt; like upgrades actually drag the price down.&lt;/p&gt;

&lt;p&gt;For example, having a &lt;strong&gt;Fence&lt;/strong&gt; or &lt;strong&gt;Alley access&lt;/strong&gt; actually correlated with a &lt;em&gt;lower&lt;/em&gt; median sale price. Why? It turns out this is a proxy for age and location. Fences and alleys are incredibly common in the older, denser urban tracts of Ames. The expensive, newly built golf-course developments don't have alleys at all!&lt;/p&gt;

&lt;h3&gt;
  
  
  🤔 My Question for the Community: Extreme Outliers
&lt;/h3&gt;

&lt;p&gt;I ran into one dilemma: &lt;strong&gt;Pools&lt;/strong&gt;. &lt;br&gt;
Pools definitely exhibited a price premium, but they were present in only 13 out of 2,930 homes (0.44%). They are an ultra-luxury edge case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you typically handle features that exist in less than 1% of the dataset?&lt;/strong&gt; &lt;br&gt;
Do you keep them as binary flags because of their predictive power on high-end outliers, or do you drop them completely due to sparsity before feeding them into a model like XGBoost?&lt;/p&gt;

&lt;p&gt;Let me know your thoughts in the comments!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you want to see the full code, you can check out my project repo on GitHub!&lt;/em&gt;&lt;br&gt;
&lt;a href="https://github.com/deepakdoriya/ames-housing-eda.git" rel="noopener noreferrer"&gt;https://github.com/deepakdoriya/ames-housing-eda.git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
      <category>eventdriven</category>
    </item>
    <item>
      <title>Why You Should Stop Reading Tutorials</title>
      <dc:creator>Deepak Doriya</dc:creator>
      <pubDate>Wed, 08 Jul 2026 17:14:26 +0000</pubDate>
      <link>https://dev.to/unknown1803/why-you-should-stop-reading-tutorials-gim</link>
      <guid>https://dev.to/unknown1803/why-you-should-stop-reading-tutorials-gim</guid>
      <description>&lt;h2&gt;
  
  
  What I Learned Auditing a World-Class Python Library (And Why You Should Stop Reading Tutorials)
&lt;/h2&gt;

&lt;p&gt;When you're learning Python, most courses follow the same path: variables, lists, basic loops, object-oriented programming. But there's a massive chasm between a tutorial script and the code that runs production-grade libraries.&lt;/p&gt;

&lt;p&gt;To bridge that gap, I recently audited the source of &lt;strong&gt;HTTPX&lt;/strong&gt; — a modern, fully typed HTTP client for Python with 100% test coverage.&lt;/p&gt;

&lt;p&gt;Here are 4 advanced patterns I found that standard tutorials never teach you — and how they hold up in real production code.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Naked Asterisk &lt;code&gt;*&lt;/code&gt;: Enforcing Clean API Calls
&lt;/h2&gt;

&lt;p&gt;When a function has 10+ optional configurations, it's easy to pass arguments in the wrong order. HTTPX prevents this using a naked asterisk &lt;code&gt;*&lt;/code&gt; in its signatures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; acts as a barrier. Every argument placed after it can no longer be passed positionally — the caller is forced to write the parameter name explicitly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ❌ Raises TypeError:
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://google.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User-Agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bot&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;# ✅ Required syntax (forces clarity):
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://google.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User-Agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bot&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; Use &lt;code&gt;*&lt;/code&gt; to force callers to write explicit, self-documenting code.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Sentinels: Solving the "Default Value" Dilemma
&lt;/h3&gt;

&lt;p&gt;We're taught to write &lt;code&gt;timeout = None&lt;/code&gt; when a parameter is optional. But what happens if &lt;code&gt;None&lt;/code&gt; is actually a valid choice for the user to make?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scenario A:&lt;/strong&gt; &lt;code&gt;client.get(url)&lt;/code&gt; — the user wants the client's default 5-second timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scenario B:&lt;/strong&gt; &lt;code&gt;client.get(url, timeout=None)&lt;/code&gt; — the user explicitly wants &lt;em&gt;no&lt;/em&gt; timeout (infinite wait).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your function signature is &lt;code&gt;timeout=None&lt;/code&gt;, you can't tell these two cases apart — omitted and "explicitly None" look identical.&lt;/p&gt;

&lt;p&gt;HTTPX solves this with a sentinel object called &lt;code&gt;USE_CLIENT_DEFAULT&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Define the sentinel
&lt;/span&gt;&lt;span class="n"&gt;USE_CLIENT_DEFAULT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;USE_CLIENT_DEFAULT&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;USE_CLIENT_DEFAULT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_timeout&lt;/span&gt;  &lt;span class="c1"&gt;# falls back to client default (e.g. 5s)
&lt;/span&gt;    &lt;span class="c1"&gt;# if the user passed None explicitly, we skip the if-block and timeout stays None
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; Use sentinels when you need to distinguish "argument omitted" from "argument explicitly set to None."&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Abstract Base Classes (ABCs): Creating Reliable Custom Types
&lt;/h3&gt;

&lt;p&gt;If you want a custom dictionary — like HTTPX's &lt;code&gt;Headers&lt;/code&gt; class, which needs case-insensitive keys — your first instinct might be to inherit from &lt;code&gt;dict&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a trap. Built-in types written in C often bypass your overrides. If you override &lt;code&gt;__setitem__&lt;/code&gt; to lowercase keys, methods like &lt;code&gt;dict.update()&lt;/code&gt; will ignore your override and write raw keys anyway.&lt;/p&gt;

&lt;p&gt;Instead, HTTPX inherits from &lt;code&gt;MutableMapping&lt;/code&gt;, an Abstract Base Class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections.abc&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;MutableMapping&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MutableMapping&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By agreeing to this "contract," you only need to implement a handful of core methods (&lt;code&gt;__getitem__&lt;/code&gt;, &lt;code&gt;__setitem__&lt;/code&gt;, &lt;code&gt;__delitem__&lt;/code&gt;, &lt;code&gt;__iter__&lt;/code&gt;, &lt;code&gt;__len__&lt;/code&gt;). Python then generates all the other dict-like methods (&lt;code&gt;.get()&lt;/code&gt;, &lt;code&gt;.pop()&lt;/code&gt;, &lt;code&gt;.update()&lt;/code&gt;) automatically — and guarantees they route through your custom logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; Never subclass &lt;code&gt;dict&lt;/code&gt; or &lt;code&gt;list&lt;/code&gt; for custom containers. Use &lt;code&gt;collections.abc&lt;/code&gt; instead.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Mypy Strict Mode: Type Safety at Scale
&lt;/h3&gt;

&lt;p&gt;Python is dynamically typed, but large-scale libraries can't afford runtime type errors. HTTPX enforces safety by running &lt;code&gt;mypy&lt;/code&gt; in strict mode. In their &lt;code&gt;pyproject.toml&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;disallow_untyped_defs = true&lt;/code&gt; — every function must be fully type-annotated.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;disallow_incomplete_defs = true&lt;/code&gt; — no partially type-hinted signatures.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;check_untyped_defs = true&lt;/code&gt; — mypy still scans untyped functions for logic bugs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; If you're publishing a library, wire up mypy strict mode from day one — retrofitting types onto an untyped codebase later is far more painful.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion: Stop Reading Tutorials, Start Auditing Code
&lt;/h3&gt;

&lt;p&gt;Instead of reading a standard Python textbook, I decided to do a codebase scavenger hunt challenge on HTTPX — hunting down specific classes, tracing parameters, and figuring out how their types are structured. It forced me to look at actual production code, and it taught me more about intermediate Python design in 30 minutes than any tutorial course could.&lt;/p&gt;

&lt;p&gt;If you want to level up, pick a library, set up a few questions to find, and start digging.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Source: &lt;a href="https://github.com/encode/httpx/blob/master/httpx/_models.py" rel="noopener noreferrer"&gt;httpx/_models.py&lt;/a&gt; on GitHub.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How Netflix Knows What You Want to Watch: Matrix Factorization &amp; Architecture</title>
      <dc:creator>Deepak Doriya</dc:creator>
      <pubDate>Fri, 03 Jul 2026 13:24:52 +0000</pubDate>
      <link>https://dev.to/unknown1803/how-netflix-knows-what-you-want-to-watch-matrix-factorization-architecture-58l8</link>
      <guid>https://dev.to/unknown1803/how-netflix-knows-what-you-want-to-watch-matrix-factorization-architecture-58l8</guid>
      <description>&lt;h2&gt;
  
  
  How Netflix Knows What You Want to Watch: Matrix Factorization &amp;amp; Architecture
&lt;/h2&gt;

&lt;p&gt;Have you ever finished a binge-worthy series on Netflix, only for the algorithm to instantly recommend the &lt;em&gt;perfect&lt;/em&gt; follow-up show? It feels like magic, but under the hood, it’s one of the most sophisticated Machine Learning systems in the world. &lt;/p&gt;

&lt;p&gt;As I dive deeper into Data Science and Machine Learning, I recently studied the architecture behind Netflix's recommendation engine. It’s not just a simple "if/then" script—it requires complex linear algebra and a highly distributed microservices architecture. Here is a technical breakdown of how it actually works.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. The Math: Matrix Factorization
&lt;/h3&gt;

&lt;p&gt;At the core of many recommendation engines is a technique called &lt;strong&gt;Matrix Factorization&lt;/strong&gt; (often implemented via Singular Value Decomposition or SVD). &lt;/p&gt;

&lt;p&gt;Imagine a massive grid (a matrix) where the rows are millions of Netflix users and the columns are thousands of movies. The cells contain ratings or engagement scores. Because most users have only watched a tiny fraction of the library, this matrix is incredibly &lt;em&gt;sparse&lt;/em&gt; (mostly empty).&lt;/p&gt;

&lt;p&gt;Matrix Factorization solves this by breaking that giant matrix down into two smaller, dense matrices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;User Matrix&lt;/strong&gt; representing latent user preferences.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Item Matrix&lt;/strong&gt; representing latent movie traits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These "latent traits" are hidden features the algorithm discovers on its own. For example, a trait might heavily correlate with "quirky indie comedies starring Steve Carell" without anyone ever explicitly programming that rule. By calculating the dot product of a user's vector and a movie's vector, the system can predict exactly how much that user will enjoy a movie they’ve never seen.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Architecture: Offline, Nearline, and Online Computation
&lt;/h3&gt;

&lt;p&gt;Matrix Factorization is computationally expensive. You can't recalculate the entire matrix for 250+ million users every time someone clicks "Play." To solve this, Netflix splits its machine learning computation into three distinct tiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Offline Computation:&lt;/strong&gt; This is the heavy lifting. Massive batch jobs run on Apache Spark or Hadoop clusters overnight or weekly. This is where models are trained on historical data and where the heavy matrix factorization occurs. It’s highly accurate but very slow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nearline Computation:&lt;/strong&gt; This tier acts asynchronously. It listens for events (like you finishing an episode) and quickly recalculates localized recommendations or updates your profile in the background. It provides a sweet spot between responsiveness and deep analysis, usually executing within seconds or minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Computation:&lt;/strong&gt; This is the real-time layer. When your app loads, this synchronous layer must respond within milliseconds. It takes the pre-computed models from the offline layer, updates them instantly with real-time context (like what device you are on or the current time of day), and serves the final ranked list to your screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Personalizing the Artwork
&lt;/h3&gt;

&lt;p&gt;Beyond ranking the shows, Netflix also relies heavily on Contextual Bandits to &lt;strong&gt;personalize the thumbnails.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;If the system recommends &lt;em&gt;Good Will Hunting&lt;/em&gt; to you, the thumbnail image you see will depend on your watch history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your user vector leans toward romance, the thumbnail might feature Matt Damon and Minnie Driver about to kiss.&lt;/li&gt;
&lt;li&gt;If your user vector leans toward comedy, the thumbnail might feature Robin Williams laughing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By optimizing the artwork dynamically, Netflix dramatically increases their Click-Through Rate (CTR).&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;At the end of the day, Netflix’s ultimate metric isn't just prediction accuracy—it is &lt;strong&gt;user retention&lt;/strong&gt;. Every model they deploy, across every tier of their architecture, is designed to keep you engaged. &lt;/p&gt;

&lt;p&gt;As I continue my journey into Machine Learning, dissecting these industry-scale systems shows just how powerful core math concepts become when paired with scalable engineering!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the most accurate recommendation an algorithm has ever given you? Let me know in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>python</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
