<?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: Hanan</title>
    <description>The latest articles on DEV Community by Hanan (@hanan_).</description>
    <link>https://dev.to/hanan_</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2593660%2F49c54e5e-5708-40d8-8ed6-d60a33fb5071.png</url>
      <title>DEV Community: Hanan</title>
      <link>https://dev.to/hanan_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hanan_"/>
    <language>en</language>
    <item>
      <title>How I Found 1,370 Fraudsters Hiding in Our Data (And Saved My Company $51,000)</title>
      <dc:creator>Hanan</dc:creator>
      <pubDate>Mon, 29 Dec 2025 23:57:11 +0000</pubDate>
      <link>https://dev.to/hanan_/how-i-found-1370-fraudsters-hiding-in-our-data-and-saved-my-company-51000-5d5</link>
      <guid>https://dev.to/hanan_/how-i-found-1370-fraudsters-hiding-in-our-data-and-saved-my-company-51000-5d5</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Tuesday, 9:14 AM&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;My manager's message was short: "We need to talk about fraud losses. My office."&lt;/p&gt;

&lt;p&gt;That's how it started—three CSV files, millions of transactions, and a sinking feeling that somewhere in those rows, fraudsters were stealing from us while we watched.&lt;/p&gt;

&lt;p&gt;I didn't know then that by Friday, I'd discover something so obvious we'd kick ourselves for not seeing it sooner.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The First Clue: When Numbers Tell a Story&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Opening the data felt like looking at two different worlds. Our credit card transactions showed fraud in just 0.5% of cases—tiny red dots in a sea of green. But our e-commerce platform? Nearly 1 in 3 transactions were fraudulent.&lt;/p&gt;

&lt;p&gt;I remember thinking: "How are we even still in business?"&lt;/p&gt;

&lt;p&gt;That's when I built my first visualization—side-by-side bars showing the stark difference. Seeing it visually made the problem real. It wasn't just numbers anymore; it was a pattern screaming for attention.&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Fk5a48oj63dz1esn9h95n.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.amazonaws.com%2Fuploads%2Farticles%2Fk5a48oj63dz1esn9h95n.png" alt=" " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Breakthrough: The 1-Hour Rule&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;It started as a hunch. "What if fraudsters work fast?"&lt;/p&gt;

&lt;p&gt;I created a simple calculation: hours between account creation and first purchase. When I plotted it, my coffee went cold.&lt;/p&gt;

&lt;p&gt;There it was—a massive spike at the beginning. Transactions within the first hour had a &lt;strong&gt;99.5% fraud rate&lt;/strong&gt;. Six thousand six hundred eighty-five cases of "sign up, steal, disappear."&lt;/p&gt;

&lt;p&gt;The visualization looked like a mountain with the peak shoved all the way to the left. It was so clear, so obvious. How had we missed this?&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Ftcslt6g04thgn62d7gzz.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.amazonaws.com%2Fuploads%2Farticles%2Ftcslt6g04thgn62d7gzz.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Building the Fraud Catchers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For credit cards, I chose XGBoost—it's like training a team of detectives who get smarter together. The results surprised me: 76 fraudsters caught, only 15 false alarms. A precision machine.&lt;/p&gt;

&lt;p&gt;For e-commerce, I went simpler with Logistic Regression. Why? Because when we flag Grandma's Christmas purchase, we need to explain why. The trade-off: slightly fewer catches (1,370 vs potential 1,409) for much better explainability.&lt;/p&gt;

&lt;p&gt;My model comparison chart told the story—different problems need different tools.&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Fh7w6sm6y4r644g621ikd.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.amazonaws.com%2Fuploads%2Farticles%2Fh7w6sm6y4r644g621ikd.png" alt=" " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Most Fascinating Part: Asking "Why?"&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Using SHAP felt like putting on X-ray glasses. Suddenly I could see what the model was thinking.&lt;/p&gt;

&lt;p&gt;The top predictors weren't what I expected. Some anonymized "V4" feature mattered most, followed by our custom anomaly score. The model was finding patterns in places I hadn't even looked.&lt;/p&gt;

&lt;p&gt;But the real magic was in the individual cases. Looking at a force plot for a caught $257 fraud, I could trace exactly why—the timing, the weird V14 value, the new account. It wasn't magic; it was math we could explain.&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Fye1d42yk91dl5ym8ake9.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.amazonaws.com%2Fuploads%2Farticles%2Fye1d42yk91dl5ym8ake9.png" alt=" " width="800" height="976"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;From Insights to Action: Three Changes We're Making&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. The 1-Hour Checkpoint&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Starting Monday, any purchase within an hour of signup gets a gentle extra verification step. Not a block—just a "Hey, confirm this is you?" Bas&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Most Fascinating Part: Asking "Why?"&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Using SHAP felt like putting on X-ray glasses. Suddenly I could see what the model was thinking.&lt;/p&gt;

&lt;p&gt;The top predictors weren't what I expected. Some anonymized "V4" feature mattered most, followed by our custom anomaly score. The model was finding patterns in places I hadn't even looked.&lt;/p&gt;

&lt;p&gt;But the real magic was in the individual cases. Looking at a force plot for a caught $257 fraud, I could trace exactly why—the timing, the weird V14 value, the new account. It wasn't magic; it was math we could explain.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;From Insights to Action: Three Changes We're Making&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. The 1-Hour Checkpoint&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Starting Monday, any purchase within an hour of signup gets a gentle extra verification step. Not a block—just a "Hey, confirm this is you?" Based on our data, this alone could stop thousands of fraudulent attempts.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Smarter Geography&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We found countries with shockingly high fraud rates (looking at you, Turkmenistan at 100%!). But we're not blocking nations—we're adding intelligent scrutiny. Legitimate customers get through; fraudsters hit roadblocks.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Dynamic Decisions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Our confusion matrices showed we need different approaches. Credit cards? Be super sure. E-commerce? Catch more, explain better. It's not one-size-fits-all.&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Fyg9jteleds3p89qlui9b.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.amazonaws.com%2Fuploads%2Farticles%2Fyg9jteleds3p89qlui9b.png" alt=" " width="800" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Business Impact (Or: How I Justified My Salary)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let's talk numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test data impact&lt;/strong&gt;: $51,000 saved&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monthly projection&lt;/strong&gt;: $200,000+&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Annual potential&lt;/strong&gt;: Millions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But more than money? &lt;strong&gt;Trust&lt;/strong&gt;. We can now tell customers exactly why their transaction was flagged. No more "the system says so" black boxes.&lt;/p&gt;

&lt;p&gt;The financial impact visualization made my case to management in 10 seconds flat.&lt;/p&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.amazonaws.com%2Fuploads%2Farticles%2Fp6tq3jzo22bdzg5btklu.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.amazonaws.com%2Fuploads%2Farticles%2Fp6tq3jzo22bdzg5btklu.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What I Wish I Knew Then&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simple beats complex&lt;/strong&gt;: The 1-hour rule required no machine learning to discover&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explainability matters&lt;/strong&gt;: Logistic Regression won for e-commerce because we could defend it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fraudsters adapt&lt;/strong&gt;: Today's patterns are tomorrow's history&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Big Realization&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The most valuable insight wasn't in the fancy algorithms. It was in asking a simple question: "What happens right after someone signs up?"&lt;/p&gt;

&lt;p&gt;Sometimes the most powerful data science is asking obvious questions and having the courage to believe the answers, even when they seem too simple to be true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want to see how we did it?&lt;/strong&gt; The code, the struggles, and the celebrations are all here: &lt;a href="https://github.com/hann2004/fraud-detection.git" rel="noopener noreferrer"&gt;https://github.com/hann2004/fraud-detection.git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question for you&lt;/strong&gt;: What's the most surprising pattern you've found in your data?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Coffee consumption during this project: 47 cups ☕&lt;br&gt;&lt;br&gt;
Regrets: Zero&lt;/em&gt;&lt;/p&gt;

</description>
      <category>frauddetection</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Crushing the Command Line: Automating Email Reading with Python &amp; Amazon Q Developer</title>
      <dc:creator>Hanan</dc:creator>
      <pubDate>Sat, 10 May 2025 19:48:30 +0000</pubDate>
      <link>https://dev.to/hanan_/crushing-the-command-line-automating-email-reading-with-python-amazon-q-developer-kj6</link>
      <guid>https://dev.to/hanan_/crushing-the-command-line-automating-email-reading-with-python-amazon-q-developer-kj6</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Terminal Email Reader: A Python Automation Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As a student balancing classes, freelance work, and personal tasks, I wanted a way to check my Gmail quickly—without leaving the terminal. So I built a Python script that fetches unread emails and displays them right in the command line, showing the sender, subject, and body.  &lt;/p&gt;

&lt;p&gt;Thanks to Amazon Q Developer CLI, I streamlined the development process by asking coding questions directly in my terminal. This is my submission for the "Crushing the Command Line" prompt of the Amazon Q Developer "Quack The Code" Challenge.  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What My Project Does&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This script:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logs into Gmail using IMAP with credentials stored securely in a &lt;code&gt;.env&lt;/code&gt; file
&lt;/li&gt;
&lt;li&gt;Fetches and decodes unread emails
&lt;/li&gt;
&lt;li&gt;Prints cleanly formatted output (sender, subject, and body) in the terminal
&lt;/li&gt;
&lt;li&gt;Uses &lt;code&gt;.gitignore&lt;/code&gt; to exclude sensitive files (like &lt;code&gt;.env&lt;/code&gt;)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How I Used Amazon Q Developer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Amazon Q Developer CLI acted like a coding assistant:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Security Setup&lt;/strong&gt;: Asked how to manage &lt;code&gt;.env&lt;/code&gt; files safely in Python projects.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IMAP Debugging&lt;/strong&gt;: Helped troubleshoot email-fetching logic and MIME decoding.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Simplification&lt;/strong&gt;: Suggested improvements to reduce complexity and improve readability.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without Q Developer, I’d have spent hours Googling—instead, I got answers right in my terminal.  &lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;How to use IMAP to access Gmail programmatically
&lt;/li&gt;
&lt;li&gt;Securing credentials with &lt;code&gt;python-dotenv&lt;/code&gt; and &lt;code&gt;.gitignore&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Decoding MIME email formats (especially tricky with Gmail’s encoding)
&lt;/li&gt;
&lt;li&gt;How powerful Amazon Q Developer is for real-time debugging and learning
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How to Run the Script&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clone the repo&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/hann2004/email-automation.git
   &lt;span class="nb"&gt;cd &lt;/span&gt;email-automation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set up your &lt;code&gt;.env&lt;/code&gt; file&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   EMAIL=your-email@gmail.com
   PASSWORD=your-app-password  # Generate this in Gmail settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Never commit &lt;code&gt;.env&lt;/code&gt; to version control.&lt;/em&gt;  &lt;/p&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; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run it&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 email_automation.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Enable IMAP in Gmail settings and create an App Password if you use 2FA.&lt;/em&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;GitHub Repository&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/hann2004/email-automation" rel="noopener noreferrer"&gt;https://github.com/hann2004/email-automation&lt;/a&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This project taught me how powerful command-line automation can be—and how tools like Amazon Q Developer make coding faster and more intuitive. Next, I’d love to add features like email filtering or mark-as-read functionality.  &lt;/p&gt;

&lt;p&gt;Thanks for reading! Feedback is welcome.  &lt;/p&gt;

</description>
      <category>awschallenge</category>
      <category>python</category>
      <category>devchallenge</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
